Hello every one,
My question is quite straight-forward. Is there any strategy for the query service to choose the best suited index to execute a query (given that we have several indexes that can be suitable for the query)?
Hello every one,
My question is quite straight-forward. Is there any strategy for the query service to choose the best suited index to execute a query (given that we have several indexes that can be suitable for the query)?
N1QL uses rule based optimization and try to use best possible index. If you think it is not using the right index you can specify by USE INDEX hint.
You can refer the articles in http://blog.couchbase.com/wp-content/uploads/2017/03/N1QL-A-Practical-Guide-v2.pdf how query selects index.
@Zak,
You can use the USE INDEX feature in your query and pick the one you want.
source: https://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-language-reference/hints.html
From there you can use the visual query tool(PLAN) to see for a give query how efficient an index is for you.
CONSOLIDATING INDEXES
You might want to consolidate indexes too
Thank you @vsr1, I will surely read this document.
Please use the second edition:
https://blog.couchbase.com/n1ql-practical-guide-second-edition/
and
https://blog.couchbase.com/create-right-index-get-right-performance/