1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-17255: New optimizer defaults and ANALYZE TABLE

Added to new values to the server variable use_stat_tables.
The values are COMPLEMENTARY_FOR_QUERIES and PREFERABLY_FOR_QUERIES.
Both these values don't allow to collect EITS for queries like
    analyze table t1;
To collect EITS we would need to use the syntax with persistent like
   analyze table t1 persistent for columns (col1,col2...) index (idx1, idx2...) / ALL

Changing the default value from NEVER to PREFERABLY_FOR_QUERIES.
This commit is contained in:
Varun Gupta
2018-12-09 13:25:27 +05:30
parent 93c360e3a5
commit 9207a838ed
12 changed files with 199 additions and 16 deletions

View File

@ -400,5 +400,47 @@ CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
SELECT MAX(pk) FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-17255: New optimizer defaults and ANALYZE TABLE
--echo #
create table t1 (a int, b int);
insert into t1(a,b) values (1,2),(1,3),(1,4),(1,5),(2,6),(2,7),(3,8),(3,9),(3,9),(4,10);
set use_stat_tables= preferably_for_queries;
--echo #
--echo # with use_stat_tables= PREFERABLY_FOR_QUERIES
--echo # analyze table t1 will not collect statistics
--echo #
analyze table t1;
select * from mysql.column_stats;
analyze
select * from t1 where a = 1 and b=3;
--echo #
--echo # with use_stat_tables= PREFERABLY_FOR_QUERIES
--echo # analyze table t1 will collect statistics if we use PERSISTENT
--echo # for columns, indexes or everything
--echo #
analyze table t1 persistent for columns (a) indexes ();
select * from mysql.column_stats;
--echo # filtered shows that we used the data from stat tables
analyze
select * from t1 where a = 1 and b=3;
--echo #
--echo # with use_stat_tables= PREFERABLY
--echo # analyze table t1 will collect statistics
--echo #
set use_stat_tables=PREFERABLY;
analyze table t1;
select * from mysql.column_stats;
--echo # filtered shows that we used the data from stat tables
analyze
select * from t1 where a=1 and b=3;
drop table t1;
set use_stat_tables=@save_use_stat_tables;