couchdb icon indicating copy to clipboard operation
couchdb copied to clipboard

Covering indexes for Mango JSON indexes

Open mikerhodes opened this issue 2 years ago • 0 comments

Summary

Provide the ability for Mango to answer a query only using an index, when that index contains all fields needed by a query.

This should speed up these queries significantly -- PoC benchmarks indicate 2-5x speedups dependent on the number of documents that need to be read from primary data. (5x seen at p90 response times between 100 and 500 documents read from primary data for a simple one-field query, on a 2022 MacBook Pro using k6.io).

Desired Behaviour

Described in https://github.com/apache/couchdb/pull/4410.

Possible Solution

Described in https://github.com/apache/couchdb/pull/4410.

Additional context

None needed beyond RFC.

General PRs

  • [x] JSON index selection tests (mango_cursor_view:choose_best_index/2)
  • [x] Add index_rows_read into mango execution stats.
  • [x] Keys only covering index.
  • [ ] Add support to index definitions to write values to JSON indexes.
    • Potentially iterate several PRs to add the restrictions and the metrics.
  • [ ] Add support for using index values in covering indexes.
  • [x] Inform user of covering index use in _explain.

mikerhodes avatar Feb 03 '23 11:02 mikerhodes