apache / apache/couchdb

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

Open
#4,865 0 comments 0 reactions 0 assignees View on GitHub
enhancement mango
Dominant language
Erlang
Stars
7k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
9

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start with Mango index scan handling for the $lt and $gt operators, tracing how inclusive_end and the start key define the interval. Compare those bounds with the selector semantics and assess how exclusive boundaries could reduce documents forwarded for in-memory filtering; done means boundary documents are no longer scanned unnecessarily without changing query results.

Written by the indexing model from the issue text.

Assessment

Tech stack
erlang
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.