Skip to content
Snippets Groups Projects
Commit 17525ed8 authored by Nikita Pettik's avatar Nikita Pettik
Browse files

sql: move SQL statistics to server

SQLite provides kind of statistics concerning data holding in each index
and space. It is used to help query planner build optimized plan. Such
statistics don't depend on internal index implementation (e.g. B-tree or
LSM tree) and contain information concerning tuple distribution.
This patch moves members responsible statistics from original SQLite
structs to Tarantool ones. To be more precise, now index's opts contains
statistics from _stat1 space (arrays of integers and their logarithm
approximation) and more sophisticated one from _stat4 (array of samples).
It also contains set of flags to turn on/off different optimizations
(such as skip-scan).

After ANALYZE command is executed, statistics are saved into _sql_stat1
and _sql_stat4 spaces (in order to persist them). However, it should also
be loaded into in-memory structs representing indexes. This patch
reworks original SQLite routine to load it directly to newly introduced
stat struct of index.

It is worth mentioning that during update of statistics occurs according
to 'everything or nothing' policy: firstly, it is allocated on the
region. Then, if there is enough memory for stats of ALL indexes it is
copied to the heap. Otherwise, region is truncated and no changes take
place.

Closes #3253
parent 946d1ebc
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment