Bug #99361 MySQL 8.0: select count(*) quey on information_schema.innodb_tables taking very
Submitted: 26 Apr 2020 16:48 Modified: 1 May 2020 18:18
Reporter: Ashok Mahajan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S1 (Critical)
Version:MySQL 8.0, 8.0.19 OS:Debian (Debian 4.19.98-1 )
Assigned to: CPU Architecture:Any ( Intel(R) Xeon(R) CPU @ 2.30GHz)

[26 Apr 2020 16:48] Ashok Mahajan
Description:
A simple count(*) query on  information_schema.innodb_tables table is taking a very long time in MySQL 8.0.

MySQL 8.0: Query execution time: 6 min 19.48 sec

mysql>  select count(*) from information_schema.innodb_tables;  show status where variable_name like 'Hander%' or variable_name like 'Created%';
+----------+
| count(*) |
+----------+
|   402561 |
+----------+
1 row in set (6 min 19.48 sec)

+-------------------------+-------+
| Variable_name           | Value |
+-------------------------+-------+
| Created_tmp_disk_tables | 1     |
| Created_tmp_files       | 0     |
| Created_tmp_tables      | 1     |
+-------------------------+-------+
3 rows in set (0.01 sec)
mysql> explain select count(*) from information_schema.innodb_tables;

Current database: *** NONE ***
+----+-------------+---------------+------------+------+---------------+------+---------+------+------+----------+-------+
| id | select_type | table         | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
+----+-------------+---------------+------------+------+---------------+------+---------+------+------+----------+-------+
|  1 | SIMPLE      | innodb_tables | NULL       | ALL  | NULL          | NULL | NULL    | NULL | NULL |     NULL | NULL  |
+----+-------------+---------------+------------+------+---------------+------+---------+------+------+----------+-------+

MySQL 5.7: Query execution time: 4.43 sec

mysql> select count(*) from information_schema.innodb_sys_tables;

Current database: *** NONE ***
+----------+
| count(*) |
+----------+
|  1197109 |
+----------+
1 row in set (4.43 sec)

mysql> explain select count(*) from information_schema.innodb_sys_tables;
+----+-------------+-------------------+------------+------+---------------+------+---------+------+------+----------+-------+
| id | select_type | table             | partitions | type | possible_keys | key  | key_len | ref  | rows | filtered | Extra |
+----+-------------+-------------------+------------+------+---------------+------+---------+------+------+----------+-------+
|  1 | SIMPLE      | innodb_sys_tables | NULL       | ALL  | NULL          | NULL | NULL    | NULL | NULL |     NULL | NULL  |
+----+-------------+-------------------+------------+------+---------------+------+---------+------+------+----------+-------+

How to repeat:
This difference in execution time is consistent through multiple executions across different servers.

Suggested fix:
NA
[27 Apr 2020 10:43] MySQL Verification Team
Hello Ashok Mahajan,

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[1 May 2020 18:18] Ashok Mahajan
Any update on this ticket ?
[9 May 2020 14:42] Alexey Kopytov
This bug may have the same root cause as bug #98449.