|
5 | 5 | * ordered by number of on disk temporary tables descending first, |
6 | 6 | * then by the number of memory tables |
7 | 7 | * |
8 | | - * mysql> SELECT * FROM statements_with_temp_tables LIMIT 5; |
9 | | - * +-------------------------------------------------------------------+------------+-------------------+-----------------+--------------------------+------------------------+----------------------------------+ |
10 | | - * | query | exec_count | memory_tmp_tables | disk_tmp_tables | avg_tmp_tables_per_query | tmp_tables_to_disk_pct | digest | |
11 | | - * +-------------------------------------------------------------------+------------+-------------------+-----------------+--------------------------+------------------------+----------------------------------+ |
12 | | - * | SELECT * FROM `data_size_per_s ... `tables` . `DATA_LENGTH` + ... | 1 | 291 | 47 | 291 | 16 | 244fd44a57e27461ec17ca76ca5c2184 | |
13 | | - * | CREATE SQL SECURITY INVOKER VI ... LIKE ? ORDER BY `timer_start` | 41 | 41 | 41 | 1 | 100 | 1a9ec5a797cd08056fdcf7142e36726b | |
14 | | - * | CREATE SQL SECURITY INVOKER VI ... SUM ( `sum_timer_wait` ) DESC | 26 | 26 | 26 | 1 | 100 | 2f473ef7b1c25a07f9eb57687e762788 | |
15 | | - * | CREATE SQL SECURITY INVOKER VI ... LIKE ? ORDER BY `timer_start` | 23 | 23 | 23 | 1 | 100 | 7c70e6abca9191142ce5092449aa9728 | |
16 | | - * | CREATE SQL SECURITY INVOKER VI ... LIKE ? ORDER BY `timer_start` | 18 | 18 | 18 | 1 | 100 | 50934f96976447cff07a8e43eff0c3f4 | |
17 | | - * +-------------------------------------------------------------------+------------+-------------------+-----------------+--------------------------+------------------------+----------------------------------+ |
18 | | - * 5 rows in set (0.00 sec) |
| 8 | + * mysql> select * from statements_with_temp_tables limit 5; |
| 9 | + * +-------------------------------------------------------------------+-------+------------+-------------------+-----------------+--------------------------+------------------------+---------------------+---------------------+----------------------------------+ |
| 10 | + * | query | db | exec_count | memory_tmp_tables | disk_tmp_tables | avg_tmp_tables_per_query | tmp_tables_to_disk_pct | first_seen | last_seen | digest | |
| 11 | + * +-------------------------------------------------------------------+-------+------------+-------------------+-----------------+--------------------------+------------------------+---------------------+---------------------+----------------------------------+ |
| 12 | + * | SELECT DISTINCTROW `agent0_` . ... gent` `agent0_` INNER JOIN ... | mem | 1423339 | 1242409 | 1242393 | 1 | 100 | 2013-12-04 20:04:48 | 2013-12-18 19:16:48 | fa4b07b4cf70914c1119ec444684dfec | |
| 13 | + * | SELECT DISTINCTROW `mysqlconne ... conne0_` . `socketPath` AS ... | mem | 67908 | 67898 | 67898 | 1 | 100 | 2013-12-04 20:04:54 | 2013-12-18 19:16:34 | fc358ad6384cc77adff425602a0a8fc1 | |
| 14 | + * | SELECT * FROM ( SELECT `digest ... ` , `sum_no_index_used` AS ... | mysql | 20113 | 140791 | 60339 | 7 | 43 | 2013-12-04 20:04:54 | 2013-12-18 19:16:34 | 50761c6a1818824328745d8a136b9ed6 | |
| 15 | + * | SELECT COUNT ( * ) FROM `INFOR ... GINS` WHERE `PLUGIN_NAME` = ? | mysql | 44248 | 44248 | 44248 | 1 | 100 | 2013-12-04 20:04:52 | 2013-12-18 19:16:34 | 090f173ed2c6c8c9b8dc60718703ff56 | |
| 16 | + * | SELECT `plugin_name` FROM `inf ... s` = ? ORDER BY `plugin_name` | mysql | 24136 | 24136 | 24136 | 1 | 100 | 2013-12-04 20:04:53 | 2013-12-18 19:16:34 | d5163a2f55578fd8e2077b8a3c00b081 | |
| 17 | + * +-------------------------------------------------------------------+-------+------------+-------------------+-----------------+--------------------------+------------------------+---------------------+---------------------+----------------------------------+ |
| 18 | + * 5 rows in set (0.02 sec) |
| 19 | + * |
| 20 | + * (Example from 5.6.14) |
19 | 21 | * |
20 | | - * (Example from 5.6.6) |
21 | | - * |
22 | | - * Versions: 5.6.5+ |
| 22 | + * Versions: 5.6.9+ |
23 | 23 | * |
24 | 24 | */ |
25 | 25 |
|
26 | 26 | DROP VIEW IF EXISTS statements_with_temp_tables; |
27 | 27 |
|
28 | 28 | CREATE SQL SECURITY INVOKER VIEW statements_with_temp_tables AS |
29 | 29 | SELECT ps_helper.format_statement(DIGEST_TEXT) AS query, |
| 30 | + SCHEMA_NAME as db, |
30 | 31 | COUNT_STAR AS exec_count, |
31 | 32 | SUM_CREATED_TMP_TABLES AS memory_tmp_tables, |
32 | 33 | SUM_CREATED_TMP_DISK_TABLES AS disk_tmp_tables, |
33 | 34 | ROUND(SUM_CREATED_TMP_TABLES / COUNT_STAR) AS avg_tmp_tables_per_query, |
34 | 35 | ROUND((SUM_CREATED_TMP_DISK_TABLES / SUM_CREATED_TMP_TABLES) * 100) AS tmp_tables_to_disk_pct, |
| 36 | + FIRST_SEEN as first_seen, |
| 37 | + LAST_SEEN as last_seen, |
35 | 38 | DIGEST AS digest |
36 | 39 | FROM performance_schema.events_statements_summary_by_digest |
37 | 40 | WHERE SUM_CREATED_TMP_TABLES > 0 |
|
0 commit comments