Reputation: 8188
If I want to get data out quickly from CouchDB is it significantly faster to grab a single doc from it's id, than to grab a view and then just use the appropriate doc in that view?
Upvotes: 3
Views: 392
Reputation: 1225
Grabbing a doc by its id uses the built-in view _all_docs
which is the primary index.
The only difference to secondary indexes as a view you mentioned is that the primary index is always up-to-date - there will never be a time lag for updating the index when the request comes in.
tl;dr Both requests variants compared have no performance differences as long as the indexes are up-to-date. Otherwise the id-lookup in the primary index wins.
Upvotes: 5