Westy
Westy

Reputation: 727

Loading a CouchDB View Index

If I need to get CouchDB to either create or recreate a large view index, is it enough to just pass in the view path in the URL with the '?limit=1', so that it doesn't send back all the data? Or will that only build the index for the first record? I other words, does CouchDB always build the entire index no matter wat the query was?

Upvotes: 0

Views: 824

Answers (1)

Dominic Barnes
Dominic Barnes

Reputation: 28429

The first time you query a CouchDB view, the entire view index will be generated, no matter what your query is. (source: documentation) Even if you specify limit=1, there is no possible way that CouchDB will know what item comes first in the list until the entire index is updated.

Once your view index is generated though, it doesn't need to be rebuilt again as it will only be updated incrementally from that point forward. If you're worried about your first user paying a penalty for querying a view, or if you have a very large database, you can always query the view yourself in order to kick things off on your own timeframe.

If you're new to CouchDB views, I would highly encourage reading their guide to views.

Upvotes: 3

Related Questions