How to get the index key size

Hi,

I just want to know how to get the key size of a composite index? It states in the “Best Practices” that a composite index should have a combined field size of 1KB. How will I know if the fields on the composite index already exceeds 1KB?

13. Avoid large keys to index

Prior to 5.0, there was a limitation on the key size for indexes(maximum 4k). This limitation has been removed in 5.0. It should be noted that indexes are meant for data access path and hence the data model and query(with indexes) should be structured to get the necessary information in shortest time. Though customers can have any number of fields in a composite index, the index key size also grows proportionally. Really large key size might impact performance. As a general rule of thumb, prefer to have 1kB as the combined size of all fields in a composite index; and if that is not possible, refactor the queries suitably.

Hi @phaigne,

Which couchbase server version are you using? Also, are you using community edition or enterprise edition ?

Currently I’m trying out the free 6.5 EE version of couchbase

From web UI, indexes tab, you can check the average index item size for each index.

In the indexes tab, you can click on the index row to expand and then click on index stats. You will see a graph showing change in average index item size over time.

Hope this helps.

I see, thanks. So the only way to check the index size is to build it? I thought there is some tool to check before creating the index.

As far as I know, there is no such tool.

Thank you @amit.kulkarni