couchdb icon indicating copy to clipboard operation
couchdb copied to clipboard

Mango `$lt` and `$gt` operators are backed by inclusive key ranges

Open pgj opened this issue 2 years ago • 0 comments

Mango index scans do not handle the $lt ("less than") and $gt ("greater than") operators efficiently. In case of $lt, inclusive_end=true is always assumed, so e.g. if there was a selector equivalent to age < 20, the key scanned would include 20 and those documents would need filtering out in memory. Similarly, for $gt, the start key is always inclusive, which cannot even be changed, i.e. there is no inclusive_start option. This can cause a bigger impact on the performance of in-memory filtering if the count is high for the documents with the start and end keys.

Investigate the possibilities for making the interval scan exclusive to cut down on the size of the set of elements forwarded for filtering.

pgj avatar Nov 21 '23 16:11 pgj