mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
88 lines
2.4 KiB
Text
88 lines
2.4 KiB
Text
--source include/have_innodb.inc
|
|
--source include/not_valgrind.inc
|
|
--source include/not_embedded.inc
|
|
--source include/have_sequence.inc
|
|
|
|
SET GLOBAL innodb_defragment_stats_accuracy = 20;
|
|
|
|
DELETE FROM mysql.innodb_index_stats;
|
|
|
|
--echo # Create table.
|
|
CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256),
|
|
KEY SECOND(a, b)) ENGINE=INNODB STATS_PERSISTENT=0;
|
|
|
|
INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
|
|
FROM seq_1_to_1024;
|
|
|
|
--echo # Not enough page splits to trigger persistent stats write yet.
|
|
SELECT * FROM mysql.innodb_index_stats;
|
|
|
|
INSERT INTO t1 SELECT 100*FLOOR(seq/70)+seq%70, REPEAT('A', 256)
|
|
FROM seq_1025_to_1433;
|
|
|
|
BEGIN;
|
|
let $num_delete = 20;
|
|
while ($num_delete)
|
|
{
|
|
eval INSERT INTO t1 SELECT 100*$num_delete+seq, REPEAT('A', 256)
|
|
FROM seq_70_to_99;
|
|
dec $num_delete;
|
|
}
|
|
ROLLBACK;
|
|
|
|
SELECT @@GLOBAL.innodb_force_recovery<2 "have background defragmentation";
|
|
|
|
# Wait for defrag_pool to be processed.
|
|
|
|
let $wait_timeout=30;
|
|
let $wait_condition = SELECT COUNT(*)>0 FROM mysql.innodb_index_stats;
|
|
--source include/wait_condition.inc
|
|
|
|
--sorted_result
|
|
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
|
|
|
|
optimize table t1;
|
|
|
|
--sorted_result
|
|
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
|
|
|
|
set global innodb_defragment_stats_accuracy = 40;
|
|
|
|
INSERT INTO t1 (b) SELECT b from t1;
|
|
|
|
--sorted_result
|
|
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
|
|
|
|
INSERT INTO t1 (b) SELECT b from t1;
|
|
|
|
--sorted_result
|
|
SELECT stat_name FROM mysql.innodb_index_stats WHERE table_name='t1';
|
|
|
|
--echo # Table rename should cause stats rename.
|
|
rename table t1 to t2;
|
|
|
|
--sorted_result
|
|
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
|
|
|
|
drop index SECOND on t2;
|
|
|
|
--echo #
|
|
--echo # MDEV-26636: Statistics must not be written for temporary tables
|
|
--echo #
|
|
SET GLOBAL innodb_defragment_stats_accuracy = 1;
|
|
CREATE TEMPORARY TABLE t (a INT PRIMARY KEY, c CHAR(255) NOT NULL)
|
|
ENGINE=InnoDB;
|
|
INSERT INTO t SELECT seq, '' FROM seq_1_to_100;
|
|
|
|
--source include/restart_mysqld.inc
|
|
|
|
--sorted_result
|
|
SELECT table_name, index_name, stat_name FROM mysql.innodb_index_stats;
|
|
|
|
--echo # Clean up
|
|
# Starting with 10.6, DROP TABLE will not touch persistent statistics
|
|
# (not defragmentation statistics either) if the table has none!
|
|
ALTER TABLE t2 STATS_PERSISTENT=1;
|
|
DROP TABLE t2;
|
|
|
|
SELECT * FROM mysql.innodb_index_stats;
|