Reputation: 1212
Is there a good way to get all ids in a database in CouchDB? I've seen this solution, but it seems kind of hackish and there must be a better way.
If I did use that solution, how well would it scale? How long would it take to find the ids of say, all 100,000 documents in a database?
Upvotes: 5
Views: 3427
Reputation: 73722
The solution from that question is the best answer. (I just edited it to make it more clear.)
Your concern that it feels hackish is valid. However, using _all_docs
is worthwhile. Firstly, it is very efficient and scalable. The list of document IDs is already stored in CouchDB. Fetching 100,000 ids (without ?include_docs=true
of course) would be very fast.
Secondly, rather than, say a plain text list, the _all_docs
response provides enough structure (the JSON rows) to be useful in the long-term. (It won't be long until you want batches of 1,000, or only ids beginning with "m", etc.)
Upvotes: 5