-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
force stats recalculation when "show table status" is called
Summary: Make innodb_stats_on_metadata a session variable and enforced for both transient and persistent stats. Test Plan: added a new test: innodb.innodb_table_status_stats Reviewers: over Reviewed By: over
- Loading branch information
Showing
7 changed files
with
84 additions
and
27 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
mysql-test/suite/innodb/r/innodb_table_status_stats.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
DROP TABLE if exists t1; | ||
# Create & populate table. | ||
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256)) ENGINE=INNODB; | ||
# Force a stats update because normal stats calculation is done in background with separate thread | ||
# thus unpredictable. | ||
analyze table t1; | ||
Table Op Msg_type Msg_text | ||
test.t1 analyze status OK | ||
pass | ||
1 | ||
# The table currently have 128 records, adding another 10 will not trigger stats recalculation by default (< 10%). | ||
# Querying the stats should not trigger a stats recalculation by default. | ||
pass | ||
1 | ||
# Querying the stats should trigger a stats recalculation when innod_stats_on_metadata is enabled. | ||
pass | ||
1 | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--source include/have_innodb.inc | ||
--source include/have_innodb_16k.inc | ||
|
||
--disable_warnings | ||
DROP TABLE if exists t1; | ||
--enable_warnings | ||
|
||
--echo # Create & populate table. | ||
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b VARCHAR(256)) ENGINE=INNODB; | ||
|
||
--disable_query_log | ||
INSERT INTO t1 VALUES (1, REPEAT('A', 256)); | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
INSERT INTO t1 (b) SELECT b from t1; | ||
--enable_query_log | ||
|
||
--echo # Force a stats update because normal stats calculation is done in background with separate thread | ||
--echo # thus unpredictable. | ||
analyze table t1; | ||
|
||
--disable_query_log | ||
--let $page_count = query_get_value(select count(*) as result from information_schema.innodb_buffer_page where table_name like '%t1%' and access_time > 0, result, 1) | ||
--let $data_length = query_get_value(select data_length from information_schema.tables where table_name='t1', data_length, 1) | ||
--eval select $page_count * 16384 = $data_length as pass | ||
|
||
--echo # The table currently have 128 records, adding another 10 will not trigger stats recalculation by default (< 10%). | ||
let $count=10; | ||
while ($count) { | ||
INSERT INTO t1 (b) VALUES (REPEAT('A', 256)); | ||
dec $count; | ||
} | ||
|
||
--let $page_count = query_get_value(select count(*) as result from information_schema.innodb_buffer_page where table_name like '%t1%' and access_time > 0, result, 1) | ||
--let $data_length = query_get_value(select data_length from information_schema.tables where table_name='t1', data_length, 1) | ||
--echo # Querying the stats should not trigger a stats recalculation by default. | ||
--eval select $page_count * 16384 != $data_length as pass | ||
|
||
set session innodb_stats_on_metadata = on; | ||
--let $page_count = query_get_value(select count(*) as result from information_schema.innodb_buffer_page where table_name like '%t1%' and access_time > 0, result, 1) | ||
--let $data_length = query_get_value(select data_length from information_schema.tables where table_name='t1', data_length, 1) | ||
--echo # Querying the stats should trigger a stats recalculation when innod_stats_on_metadata is enabled. | ||
--eval select $page_count * 16384 = $data_length as pass | ||
|
||
--enable_query_log | ||
|
||
# Clean up | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters