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
Showing
- extra/mkkeywordhash.c 1 addition, 6 deletionsextra/mkkeywordhash.c
- src/box/index_def.c 67 additions, 0 deletionssrc/box/index_def.c
- src/box/index_def.h 113 additions, 0 deletionssrc/box/index_def.h
- src/box/sql/analyze.c 515 additions, 409 deletionssrc/box/sql/analyze.c
- src/box/sql/build.c 0 additions, 61 deletionssrc/box/sql/build.c
- src/box/sql/parse.y 0 additions, 2 deletionssrc/box/sql/parse.y
- src/box/sql/pragma.c 1 addition, 2 deletionssrc/box/sql/pragma.c
- src/box/sql/prepare.c 2 additions, 5 deletionssrc/box/sql/prepare.c
- src/box/sql/sqliteInt.h 38 additions, 25 deletionssrc/box/sql/sqliteInt.h
- src/box/sql/vdbe.c 2 additions, 3 deletionssrc/box/sql/vdbe.c
- src/box/sql/where.c 121 additions, 53 deletionssrc/box/sql/where.c
- src/box/sql/whereexpr.c 1 addition, 3 deletionssrc/box/sql/whereexpr.c
- test/sql-tap/gh-3350-skip-scan.test.lua 1 addition, 1 deletiontest/sql-tap/gh-3350-skip-scan.test.lua
Loading
Please register or sign in to comment