Bug #74935 | innodb index stats inadequate using constant innodb_stats_sample_pages | ||
---|---|---|---|
Submitted: | 20 Nov 2014 8:09 | Modified: | 22 Nov 2014 11:43 |
Reporter: | Jan Lindstrom | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S3 (Non-critical) |
Version: | 5.5,5.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[20 Nov 2014 8:09]
Jan Lindstrom
[20 Nov 2014 8:10]
Jan Lindstrom
MariaDB [test]> select count(*) from obs_daily; +----------+ | count(*) | +----------+ | 1048576 | +----------+ 1 row in set (2.22 sec) MariaDB [test]> select count(distinct sLocType) from obs_daily; +--------------------------+ | count(distinct sLocType) | +--------------------------+ | 1 | +--------------------------+ 1 row in set (0.01 sec) MariaDB [test]> select count(distinct sLocCode) from obs_daily; +--------------------------+ | count(distinct sLocCode) | +--------------------------+ | 1007624 | +--------------------------+ 1 row in set (5.65 sec) MariaDB [test]> select count(distinct dtDate) from obs_daily; +------------------------+ | count(distinct dtDate) | +------------------------+ | 15 | +------------------------+ 1 row in set (0.00 sec) MariaDB [test]> set global innodb_stats_sample_pages = 8; Query OK, 0 rows affected (0.00 sec) MariaDB [test]> analyze table obs_daily; +----------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +----------------+---------+----------+----------+ | test.obs_daily | analyze | status | OK | +----------------+---------+----------+----------+ 1 row in set (0.02 sec) MariaDB [test]> select * from information_schema.INNODB_INDEX_STATS where table_name='obs_daily'; +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | table_schema | table_name | index_name | fields | rows_per_key | index_total_pages | index_leaf_pages | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | test | obs_daily | PRIMARY | 1 | 1 | 2852 | 2844 | | test | obs_daily | idx_obs_daily_1 | 3 | 115183, 0, 0 | 3628 | 3138 | | test | obs_daily | idx_obs_daily_2 | 2 | 115183, 0 | 865 | 814 | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ 3 rows in set (0.00 sec) MariaDB [test]> analyze table obs_daily; +----------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +----------------+---------+----------+----------+ | test.obs_daily | analyze | status | OK | +----------------+---------+----------+----------+ 1 row in set (0.02 sec) MariaDB [test]> select * from information_schema.INNODB_INDEX_STATS where table_name='obs_daily'; +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | table_schema | table_name | index_name | fields | rows_per_key | index_total_pages | index_leaf_pages | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | test | obs_daily | PRIMARY | 1 | 1 | 2852 | 2844 | | test | obs_daily | idx_obs_daily_1 | 3 | 116842, 1, 0 | 3628 | 3138 | | test | obs_daily | idx_obs_daily_2 | 2 | 116842, 0 | 865 | 814 | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ 3 rows in set (0.00 sec) MariaDB [test]> analyze table obs_daily; +----------------+---------+----------+----------+ | Table | Op | Msg_type | Msg_text | +----------------+---------+----------+----------+ | test.obs_daily | analyze | status | OK | +----------------+---------+----------+----------+ 1 row in set (0.02 sec) MariaDB [test]> select * from information_schema.INNODB_INDEX_STATS where table_name='obs_daily'; +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | table_schema | table_name | index_name | fields | rows_per_key | index_total_pages | index_leaf_pages | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ | test | obs_daily | PRIMARY | 1 | 1 | 2852 | 2844 | | test | obs_daily | idx_obs_daily_1 | 3 | 116407, 1, 1 | 3628 | 3138 | | test | obs_daily | idx_obs_daily_2 | 2 | 116407, 0 | 865 | 814 | +--------------+------------+-----------------+--------+--------------+-------------------+------------------+ 3 rows in set (0.00 sec)
[20 Nov 2014 8:10]
Jan Lindstrom
For more discussion see: https://mariadb.atlassian.net/browse/MDEV-7084
[20 Nov 2014 8:11]
Jan Lindstrom
Test file
Attachment: innodb_mdev7084.test (application/octet-stream, text), 3.34 KiB.
[20 Nov 2014 8:11]
Jan Lindstrom
mtr options
Attachment: innodb_mdev7084-master.opt (application/octet-stream, text), 22 bytes.
[20 Nov 2014 8:12]
Jan Lindstrom
Suggested fix for 5.5. (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: patch.diff (text/x-patch), 17.44 KiB.
[22 Nov 2014 11:43]
MySQL Verification Team
Hello Jan Lindstrom, Thank you for the report and contribution. Thanks, Umesh