You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The new index method finds a quantile point in an indexed data range.
It takes the quantile level (0 < L < 1) and optionally the target range
boundaries and returns such a key that the ratio of tuples less than
the key equals L.
Example:
locals=box.schema.space.create('test')
s:create_index('pk')
fori=1, 100dos:insert({i*i, i})
end-- Find the median in the whole index.s.index.pk:quantile(0.5) -- returns {2601}-- Find the 90th percentile among all keys < 1000s.index.pk:quantile(0.9, {}, {1000}) -- returns {784}
The target range is defined as the intersection of the following read
requests:
This means that using the empty key {} or nil for both begin_key
and end_key finds the quantile in the whole index. The function raises
an error if there can't possibly be any tuples in the target range, i.e.
if key_begin >= key_end.
The function returns nil if there are no tuples in the target
range or if it failed to find the quantile due to the limitations of
the storage engine, which are described below.
The function is implemented by memtx and vinyl tree indexes only.
In memtx the function returns the quantile point exactly. It has
the logarithmic complexity. It may return nil only if there are
no tuples in the target range. There's guaranteed to be a tuple
in the target range corresponding to the returned key.
The vinyl implementation returns the quantile point with a reasonable
degree of error for performance considerations. It has the logarithmic
complexity as well. There may or may not be a tuple in the target
range corresponding to the returned key. The function may return nil
even if the target range is not empty, in particular, if there are
no disk layers or if the range is smaller than the vinyl page size.
The function doesn't yield.
The function doesn't participate in transactions.
Like other index methods, index:quantile() can be used through
a space object as space:quantile(), in which case it works as
a shortcut for the primary index.
The new index method finds a quantile point in an indexed data range.
It takes the quantile level (0 < L < 1) and optionally the target range
boundaries and returns such a key that the ratio of tuples less than
the key equals L.
Example:
The target range is defined as the intersection of the following read
requests:
This means that using the empty key
{}
ornil
for bothbegin_key
and
end_key
finds the quantile in the whole index. The function raisesan error if there can't possibly be any tuples in the target range, i.e.
if
key_begin
>=key_end
.The function returns
nil
if there are no tuples in the targetrange or if it failed to find the quantile due to the limitations of
the storage engine, which are described below.
The function is implemented by memtx and vinyl tree indexes only.
In memtx the function returns the quantile point exactly. It has
the logarithmic complexity. It may return
nil
only if there areno tuples in the target range. There's guaranteed to be a tuple
in the target range corresponding to the returned key.
The vinyl implementation returns the quantile point with a reasonable
degree of error for performance considerations. It has the logarithmic
complexity as well. There may or may not be a tuple in the target
range corresponding to the returned key. The function may return nil
even if the target range is not empty, in particular, if there are
no disk layers or if the range is smaller than the vinyl page size.
The function doesn't yield.
The function doesn't participate in transactions.
Like other index methods,
index:quantile()
can be used througha space object as
space:quantile()
, in which case it works asa shortcut for the primary index.
For more details, see the RFC document: https://github.com/orgs/tarantool/discussions/11194
Requested by @locker in tarantool/tarantool@a8df9b5.
The text was updated successfully, but these errors were encountered: