| 1 |
# |
| 2 |
# Test the persistent stats auto recalc when persistent stats do not exist |
| 3 |
# |
| 4 |
|
| 5 |
|
| 6 |
-- vertical_results |
| 7 |
|
| 8 |
-- let $check_stats1 = SELECT COUNT(*) FROM mysql.innodb_table_stats WHERE table_name = 't' |
| 9 |
-- let $check_stats2 = SELECT COUNT(*) FROM mysql.innodb_index_stats WHERE table_name = 't' |
| 10 |
|
| 11 |
-- echo Test with default setting |
| 12 |
|
| 13 |
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB; |
| 14 |
|
| 15 |
# the CREATE should have inserted zeroed stats |
| 16 |
-- eval $check_stats1 |
| 17 |
-- eval $check_stats2 |
| 18 |
|
| 19 |
# close the table |
| 20 |
FLUSH TABLE t; |
| 21 |
|
| 22 |
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't'; |
| 23 |
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't'; |
| 24 |
|
| 25 |
-- eval $check_stats1 |
| 26 |
-- eval $check_stats2 |
| 27 |
|
| 28 |
# open the table, causing stats recalc/save |
| 29 |
SELECT * FROM t; |
| 30 |
|
| 31 |
-- eval $check_stats1 |
| 32 |
-- eval $check_stats2 |
| 33 |
|
| 34 |
DROP TABLE t; |
| 35 |
|
| 36 |
-- echo Test with explicit enable |
| 37 |
|
| 38 |
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=1; |
| 39 |
|
| 40 |
# the CREATE should have inserted zeroed stats |
| 41 |
-- eval $check_stats1 |
| 42 |
-- eval $check_stats2 |
| 43 |
|
| 44 |
# close the table |
| 45 |
FLUSH TABLE t; |
| 46 |
|
| 47 |
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't'; |
| 48 |
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't'; |
| 49 |
|
| 50 |
-- eval $check_stats1 |
| 51 |
-- eval $check_stats2 |
| 52 |
|
| 53 |
# open the table, causing stats recalc/save |
| 54 |
SELECT * FROM t; |
| 55 |
|
| 56 |
-- eval $check_stats1 |
| 57 |
-- eval $check_stats2 |
| 58 |
|
| 59 |
DROP TABLE t; |
| 60 |
|
| 61 |
-- echo Test with explicit disable |
| 62 |
|
| 63 |
CREATE TABLE t (a INT, PRIMARY KEY (a)) ENGINE=INNODB STATS_AUTO_RECALC=0; |
| 64 |
|
| 65 |
# the CREATE should have inserted zeroed stats |
| 66 |
-- eval $check_stats1 |
| 67 |
-- eval $check_stats2 |
| 68 |
|
| 69 |
# close the table |
| 70 |
FLUSH TABLE t; |
| 71 |
|
| 72 |
DELETE FROM mysql.innodb_index_stats WHERE table_name = 't'; |
| 73 |
DELETE FROM mysql.innodb_table_stats WHERE table_name = 't'; |
| 74 |
|
| 75 |
-- eval $check_stats1 |
| 76 |
-- eval $check_stats2 |
| 77 |
|
| 78 |
# open the table, stats should not be present, since autorecalc is disabled |
| 79 |
SELECT * FROM t; |
| 80 |
|
| 81 |
-- eval $check_stats1 |
| 82 |
-- eval $check_stats2 |
| 83 |
|
| 84 |
DROP TABLE t; |