Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit f28a394

Browse files
committed
adding db, first_seen, last_seen
1 parent 2f6b9c2 commit f28a394

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

views/p_s/statements_with_temp_tables.sql

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,36 @@
55
* ordered by number of on disk temporary tables descending first,
66
* then by the number of memory tables
77
*
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)
1921
*
20-
* (Example from 5.6.6)
21-
*
22-
* Versions: 5.6.5+
22+
* Versions: 5.6.9+
2323
*
2424
*/
2525

2626
DROP VIEW IF EXISTS statements_with_temp_tables;
2727

2828
CREATE SQL SECURITY INVOKER VIEW statements_with_temp_tables AS
2929
SELECT ps_helper.format_statement(DIGEST_TEXT) AS query,
30+
SCHEMA_NAME as db,
3031
COUNT_STAR AS exec_count,
3132
SUM_CREATED_TMP_TABLES AS memory_tmp_tables,
3233
SUM_CREATED_TMP_DISK_TABLES AS disk_tmp_tables,
3334
ROUND(SUM_CREATED_TMP_TABLES / COUNT_STAR) AS avg_tmp_tables_per_query,
3435
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,
3538
DIGEST AS digest
3639
FROM performance_schema.events_statements_summary_by_digest
3740
WHERE SUM_CREATED_TMP_TABLES > 0

0 commit comments

Comments
 (0)