How do indexes actually work?
I watched the webinars about views and indexes and I have a few questions I hope someone will answer.
Are indices updated whenever new documents are posted, or are they only updated when the view is requested? (If they're updated incrementally whenever new documents are posted, why can a query specify that the index should be rebuilt?)
What is the likely performance of an index over a database with 10 million objects? Is the expected return time likely to be within seconds? minutes? hours?
Does adding each index impact performance of PUT operations in a significant way?
Thanks in advance!
Thanks for the info!
Can you address the expected query time (will it take seconds, minutes, or hours to build/update an index)?
If an index is already being updated and another query (with stale=update_after) is sent, will the 2nd update queue up, or will it notice that an update is already happening and ignore the second one?
Also, at what point are expired records removed from a view? I understand that documents are expired lazily (only when retrieved), but does that apply to index creation as well? Will a document be removed from an index once the index is rebuilt after it's expiration time, or will it stay in the index until after I access it and then rebuild the index?
Hi tombrown52
Indexes do not get built when new documents are posted/inserted but rather when the view is accessed. They are built incrementally after the first index build. Index building is triggered after a query accesses a view. This is subject to the "stale" argument that can be set at query time. (http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writi...). Starting DP4, the default for the "stale" argument is "update_after".
This section in the documentation provides more details on how views work: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-datas...
Index performance dependents largely on the view definitions. If the view definitions are fairly complex or emit entire documents (bad practice), index building can take longer. The number of design documents you have also has an impact on system performance. Grouping similar views (that have a similar access pattern) into a single design document helps improve performance as all views in a design document are built together.
Hope this helps.