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

MDEV-17605 Statistics for InnoDB table is wrong if persistent statistics is used

The command SHOW INDEXES ignored setting of the system variable
use_stat_tables to the value of 'preferably' and and showed statistical
data received from the engine. Similarly queries over the table
STATISTICS from INFORMATION_SCHEMA ignored this setting. It happened
because the function fill_schema_table_by_open() did not read any data
from statistical tables.
This commit is contained in:
Igor Babaev
2019-04-22 17:10:42 -07:00
parent a4f7d85932
commit 279a907fd0
6 changed files with 204 additions and 1 deletions

View File

@ -402,3 +402,57 @@ SELECT MAX(pk) FROM t1;
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # MDEV-17605: SHOW INDEXES with use_stat_tables='preferably'
--echo #
set use_stat_tables='preferably';
CREATE DATABASE dbt3_s001;
use dbt3_s001;
set @save_optimizer_switch=@@optimizer_switch;
set optimizer_switch='extended_keys=off';
--disable_query_log
--disable_result_log
--disable_warnings
--source include/dbt3_s001.inc
create index i_p_retailprice on part(p_retailprice);
delete from mysql.table_stats;
delete from mysql.column_stats;
delete from mysql.index_stats;
ANALYZE TABLE lineitem;
FLUSH TABLE mysql.table_stats, mysql.index_stats;
--enable_warnings
--enable_result_log
--enable_query_log
select * from mysql.table_stats;
select * from mysql.index_stats;
SHOW INDEXES FROM lineitem;
SELECT * FROM INFORMATION_SCHEMA.STATISTICS WHERE table_name='lineitem';
SELECT
COUNT(DISTINCT l_orderkey), COUNT(DISTINCT l_orderkey,l_linenumber),
COUNT(DISTINCT l_shipDATE),
COUNT(DISTINCT l_partkey), COUNT(DISTINCT l_partkey,l_suppkey),
COUNT(DISTINCT l_suppkey), COUNT(DISTINCT l_receiptDATE),
COUNT(DISTINCT l_orderkey, l_quantity), COUNT(DISTINCT l_commitDATE)
FROM lineitem;
set optimizer_switch=@save_optimizer_switch;
DROP DATABASE dbt3_s001;
delete from mysql.table_stats;
delete from mysql.column_stats;
delete from mysql.index_stats;
set @save_optimizer_switch=@@optimizer_switch;
set use_stat_tables=@save_use_stat_tables;