Description
Product: Tarantool
Since: 3.3.0
Root document:
- https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/count/#lua-function.index_object.count
- https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_index/select/#lua-function.index_object.select
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 tarantool/tarantool@421d36f.