incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabio Forno <fabio.fo...@gmail.com>
Subject counting rows in range queries
Date Thu, 30 Jul 2009 00:38:15 GMT
Hi,
I've read many threads explaining how to count rows in view results,
however I can't find any working solution for this particular case.
I've a set of items divided in buckets, and each item has a posting
date. I want to divide the items per bucket and sort them by their
date, so I make a view with this key:
[item.bucket, item.date]

Now the difficult part. There are many consumers who retrieve the
items from the buckets and each consumers knows the date of the last
item it has retrieved, so I do a range query on the view with
startkey=[item.bucket, last_date], endkey=[item.bucket, stopper]. This
is fine, but if I want to tell the user how many items it has to
retrieve before actually downloading them I can't do nothing but
retrieving all the rows and start counting. Any idea for solving this
with a proper map reduce, or some clever doc structure?
The only possible solution I've found so far is storing marker
documents for each possible consumer (containing just the item id) any
time I post a new item in a bucket. These can be counted with a
map/reduce and deleted when the items are retrieved, but I really
don't like the solution since it requires too many writes.

bye!

-- 
Fabio Forno, Ph.D.
Bluendo srl http://www.bluendo.com
jabber id: ff@jabber.bluendo.com

Mime
View raw message