Bug #92195 checking permissions 90 time
Submitted: 26 Aug 2018 13:51 Modified: 30 Aug 2018 12:37
Reporter: NOT_FOUND NULL ! Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S5 (Performance)
Version:8.0.12 OS:CentOS
Assigned to: CPU Architecture:x86
Tags: checking permissions 90 time

[26 Aug 2018 13:51] NOT_FOUND NULL !
Description:
With profiling i see that it try to 'checking permissions' 90 times and the last one has high DURATION

mysql> SELECT @@version;
+-----------+
| @@version |
+-----------+
| 8.0.12    |
+-----------+
1 row in set (0.00 sec)

mysql>
mysql> DROP TABLE IF EXISTS `bug`;
Query OK, 0 rows affected (0.07 sec)

mysql>
mysql>
mysql> CREATE TABLE `bug` (
    ->   `bug` tinyint(3) unsigned NOT NULL
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql> SET SESSION profiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>
mysql> SHOW fields FROM `bug`;
+-------+---------------------+------+-----+---------+-------+
| Field | Type                | Null | Key | Default | Extra |
+-------+---------------------+------+-----+---------+-------+
| bug   | tinyint(3) unsigned | NO   |     | NULL    |       |
+-------+---------------------+------+-----+---------+-------+
1 row in set (0.51 sec)

mysql>
mysql> SHOW PROFILES;
+----------+------------+------------------------+
| Query_ID | Duration   | Query                  |
+----------+------------+------------------------+
|        1 | 0.50274725 | SHOW fields FROM `bug` |
+----------+------------+------------------------+
1 row in set, 1 warning (0.00 sec)

mysql>
mysql> SELECT STATE, SUM(DURATION) AS Total_R, COUNT(*) AS Calls, SUM(DURATION) / COUNT(*) AS "R/Call", SUM(CPU_USER) CPU_USER, SUM(CPU_SYSTEM) CPU_SYSTEM, SUM(CONTEXT_VOLUNTARY) CONTEXT_VOLUNTARY, SUM(CONTEXT_INVOLUNTARY) CONTEXT_INVOLUNTARY, SUM(BLOCK_OPS_IN) BLOCK_OPS_IN, SUM(BLOCK_OPS_OUT) BLOCK_OPS_OUT, SUM(MESSAGES_SENT) MESSAGES_SENT, SUM(MESSAGES_RECEIVED) MESSAGES_RECEIVED, SUM(PAGE_FAULTS_MAJOR) PAGE_FAULTS_MAJOR, SUM(PAGE_FAULTS_MINOR) PAGE_FAULTS_MINOR, SUM(SWAPS) SWAPS  FROM INFORMATION_SCHEMA.PROFILING GROUP BY STATE ORDER BY Total_R DESC;
+----------------------+----------+-------+--------------+----------+------------+-------------------+---------------------+--------------+---------------+---------------+-------------------+-------------------+-------------------+-------+
| STATE                | Total_R  | Calls | R/Call       | CPU_USER | CPU_SYSTEM | CONTEXT_VOLUNTARY | CONTEXT_INVOLUNTARY | BLOCK_OPS_IN | BLOCK_OPS_OUT | MESSAGES_SENT | MESSAGES_RECEIVED | PAGE_FAULTS_MAJOR | PAGE_FAULTS_MINOR | SWAPS |
+----------------------+----------+-------+--------------+----------+------------+-------------------+---------------------+--------------+---------------+---------------+-------------------+-------------------+-------------------+-------+
| checking permissions | 0.074314 |    90 | 0.0008257111 | 0.074576 |   0.000000 |                13 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| removing tmp table   | 0.000595 |     2 | 0.0002975000 | 0.000599 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| Creating sort index  | 0.000134 |     1 | 0.0001340000 | 0.000123 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| freeing items        | 0.000099 |     1 | 0.0000990000 | 0.000102 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| query end            | 0.000054 |     3 | 0.0000180000 | 0.000050 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| closing tables       | 0.000037 |     1 | 0.0000370000 | 0.000036 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| cleaning up          | 0.000015 |     1 | 0.0000150000 | 0.000014 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
| end                  | 0.000015 |     1 | 0.0000150000 | 0.000012 |   0.000000 |                 0 |                   0 |            0 |             0 |             0 |                 0 |                 0 |                 0 |     0 |
+----------------------+----------+-------+--------------+----------+------------+-------------------+---------------------+--------------+---------------+---------------+-------------------+-------------------+-------------------+-------+
8 rows in set, 1 warning (0.00 sec)

mysql>
mysql> SELECT * FROM INFORMATION_SCHEMA.PROFILING;

How to repeat:
SELECT @@version;

DROP TABLE IF EXISTS `bug`;

CREATE TABLE `bug` (
  `bug` tinyint(3) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC;

SET SESSION profiling = 1;

SHOW fields FROM `bug`;

SHOW PROFILES;

SELECT STATE, SUM(DURATION) AS Total_R, COUNT(*) AS Calls, SUM(DURATION) / COUNT(*) AS "R/Call", SUM(CPU_USER) CPU_USER, SUM(CPU_SYSTEM) CPU_SYSTEM, SUM(CONTEXT_VOLUNTARY) CONTEXT_VOLUNTARY, SUM(CONTEXT_INVOLUNTARY) CONTEXT_INVOLUNTARY, SUM(BLOCK_OPS_IN) BLOCK_OPS_IN, SUM(BLOCK_OPS_OUT) BLOCK_OPS_OUT, SUM(MESSAGES_SENT) MESSAGES_SENT, SUM(MESSAGES_RECEIVED) MESSAGES_RECEIVED, SUM(PAGE_FAULTS_MAJOR) PAGE_FAULTS_MAJOR, SUM(PAGE_FAULTS_MINOR) PAGE_FAULTS_MINOR, SUM(SWAPS) SWAPS  FROM INFORMATION_SCHEMA.PROFILING GROUP BY STATE ORDER BY Total_R DESC;

SELECT * FROM INFORMATION_SCHEMA.PROFILING;
[30 Aug 2018 12:37] MySQL Verification Team
Hi,

Table PROFILING in INFORMATION_SCHEMA is deprecated, hence we do not verify bugs for that particular table.

Instead, please use a table with the same name from the PERFORMANCE_SCHEMA and see if you get any better results.