tarantool / tarantool/doc

select with offset and count are now logarithmic in memtx tree

Open
#4,502 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.3 index reference
Dominant language
CSS
Stars
15
Forks
49
Avg merge
1d 13h
Merged PRs (30d)
3

Description

Product: Tarantool
Since: 3.3.0
Root document:

SME: @ mkostoevr

Details

Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/count/#lua-function.index_object.count

Iterate over an index, counting the number of tuples which match
the key-value.

This is no longer true for the memtx tree index, where count has a
logarithmic complexity (O(log(size)) where size is the amount of
tuples in the index) and it does not iterate over the index.


Root document: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/select/#lua-function.index_object.select

offset – the number of tuples to skip (use this parameter carefully
when scanning large data sets).

The part about large datasets is not actual for the memtx tree index
now, since the complexity of select with offset there is logarithmic
too (it does not scan the space either).

Use the offset option carefully when scanning large data sets as it
linearly increases the number of scanned tuples and leads to a full
space scan. Instead, you can use the after and fetch_pos options.

Ditto.


Root document: https://www.tarantool.io/en/doc/latest/platform/engines/memtx_vinyl_diff/

count() function Takes a constant amount of time

Now it takes logarithmic time as mentioned above.
Requested by @mkostoevr in https://github.com/tarantool/tarantool/commit/421d36f2e144ae2ebe54a2e9ef1ede3278cd5c69.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked box_index.count, box_index.select, and memtx_vinyl_diff documentation pages. Update the statements about count() and select() offset complexity to reflect the memtx tree behavior described in the issue, and remove or revise the warnings that no longer apply. Done means all three references consistently describe the current complexity and scanning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.