You are here
Temporary tables and MySQL STATUS information
Fri, 2016-07-08 18:42 — Shinguz
When analysing MySQL configuration and status information at customers it is always interesting to see how the applications behave. This can partially be seen by the output of the SHOW GLOBAL STATUS command. See also Reading MySQL fingerprints.
Today we wanted to know where the high Com_create_table and the twice as high Com_drop_table is coming from. One suspect was TEMPORARY TABLES. But are real temporary tables counted as Com_create_table and Com_drop_table at all? This is what we want to find out today. The tested MySQL version is 5.7.11.
Caution: Different MySQL or MariaDB versions might behave differently!
| Session 1 | Global | Session 2 |
|---|---|---|
CREATE TABLE t1 (id INT); |
||
Com_create_table +1 |
Com_create_table +1 |
|
CREATE TABLE t1 (id INT); |
||
Com_create_table +1 |
Com_create_table + 1 |
|
CREATE TABLE t1 (id INT); |
||
Com_create_table + 1 |
Com_create_table + 1 |
|
DROP TABLE t1; |
||
Com_drop_table +1 |
Com_drop_table +1 |
|
DROP TABLE t1; |
||
Com_drop_table -1 |
Com_drop_table -1 |
|
CREATE TEMPORARY TABLE ttemp (id INT); |
||
Com_create_table +1 |
Com_create_table +1 |
|
CREATE TEMPORARY TABLE ttemp (id INT); |
||
Com_create_table +1 |
Com_create_table +1 |
|
DROP TABLE ttemp; |
||
Com_drop_table +1 |
Com_drop_table +1 |
|
CREATE TEMPORARY TABLE ttemp (id int); |
CREATE TEMPORARY TABLE ttemp (id int); |
|
Com_create_table +1 |
Com_create_table +2 |
Com_create_table +1 |
DROP TABLE ttemp; |
DROP TABLE ttemp; |
|
Com_drop_table +1 |
Com_drop_table +2 |
Com_drop_table +1 |
Conclusion
- A successful
CREATE TABLEcommand opens and closes a table definition. - A non successful
CREATE TABLEcommand opens the table definition and the file handle of the previous table. So a faulty application can be quite expensive. - A further non successful
CREATE TABLEcommand has no other impact. - A
DROP TABLEcommand closes a table definition and the file handle. - A
CREATE TEMPORARY TABLEopens 2 table definitions and the file handle. Thus behaves different thanCREATE TABLE - But a faulty
CREATE TEMPORARY TABLEseems to be much less intrusive. Open_table_definitionsandOpen_tablesis always global, also in session context.
Taxonomy upgrade extras: