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

Commit 4002346

Browse files
committed
Update statements_with_runtimes_in_95th_percentile.sql
adding db, rows_examined_avg, first_seen, last_seen
1 parent a0197ea commit 4002346

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

views/p_s/statements_with_runtimes_in_95th_percentile.sql

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,29 @@ HAVING percentile > 0.95
4646
*
4747
* List all statements who's average runtime, in microseconds, is in the top 95th percentile.
4848
*
49-
* mysql> select * from statements_with_runtimes_in_95th_percentile where query not like 'show%';
50-
* +-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+
51-
* | query | full_scan | exec_count | err_count | warn_count | total_latency | max_latency | avg_latency | rows_sent | rows_sent_avg | rows_scanned | digest |
52-
* +-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+
53-
* | SELECT plugin_name FROM inform ... tus = ? ORDER BY plugin_name | * | 169 | 0 | 0 | 2.37 s | 64.45 ms | 14.03 ms | 4394 | 26 | 10816 | 23234b56a0b1f1e350bf51bef3050747 |
54-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 170.08 ms | 5.68 ms | 1.44 ms | 13582 | 115 | 13582 | 34694223091aee1380c565076b7dfece |
55-
* | SELECT CAST ( SUM_NUMBER_OF_BY ... WHERE EVENT_NAME = ? LIMIT ? | * | 566 | 0 | 0 | 779.56 ms | 2.93 ms | 1.38 ms | 342 | 1 | 17286 | 58d34495d29ad818e68c859e778b0dcb |
56-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 153.35 ms | 3.06 ms | 1.30 ms | 13228 | 112 | 13228 | b816579565d5a2882cb8bd496193dc00 |
57-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 143.31 ms | 4.57 ms | 1.21 ms | 13646 | 116 | 13646 | 27ff8681eb2c8cf999233e7507b439fe |
58-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 143.04 ms | 7.22 ms | 1.21 ms | 13584 | 115 | 13584 | 10b863f20e83dcd9c7782dac249acbb0 |
59-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 137.46 ms | 16.73 ms | 1.16 ms | 13922 | 118 | 13922 | 351ebc26af6babb67570843bcc97f6b0 |
60-
* | UPDATE `mem30__inventory` . `R ... mestamp` = ? WHERE `hid` = ? | | 114 | 0 | 0 | 127.64 ms | 30.33 ms | 1.12 ms | 0 | 0 | 114 | f4ecf2aebe212e7ed250a0602d86c389 |
61-
* | UPDATE `mem30__inventory` . `I ... ` = ? , `hasOldBlocksTime` ... | | 56 | 0 | 0 | 61.05 ms | 16.41 ms | 1.09 ms | 0 | 0 | 56 | cdc78c70d83c505c5708847ba810d035 |
62-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 121.76 ms | 1.95 ms | 1.03 ms | 13936 | 118 | 13936 | 20f97c53c2a59f5eadc06b2fa90fbe75 |
63-
* | UPDATE `mem30__inventory` . `M ... mpileOs` = ? WHERE `hid` = ? | | 114 | 0 | 0 | 114.16 ms | 22.34 ms | 1.00 ms | 0 | 0 | 114 | c5d4a65f3f308f4869807e730739af6d |
64-
* | CALL `dc_string_insert` (...) | | 80 | 0 | 0 | 79.89 ms | 2.62 ms | 998.50 ┬╡s | 0 | 0 | 240 | 93eb9cab8ced45cf3b98400e8803f8af |
65-
* | SELECT `this_` . `target` AS ` ... D `this_` . `timestamp` <= ? | | 118 | 0 | 0 | 116.19 ms | 1.32 ms | 984.60 ┬╡s | 13484 | 114 | 13484 | bd23afed9a41367591e2b71dac76f334 |
66-
* +-------------------------------------------------------------------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+--------------+----------------------------------+
49+
* mysql> select * from statements_with_runtimes_in_95th_percentile limit 5;
50+
* +-------------------------------------------------------------------+------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
51+
* | query | db | full_scan | exec_count | err_count | warn_count | total_latency | max_latency | avg_latency | rows_sent | rows_sent_avg | rows_examined | rows_examined_avg | FIRST_SEEN | LAST_SEEN | digest |
52+
* +-------------------------------------------------------------------+------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
53+
* | SELECT `e` . `round_robin_bin` ... `timestamp` = `maxes` . `ts` | mem | * | 14 | 0 | 0 | 43.96 s | 6.69 s | 3.14 s | 11 | 1 | 253170 | 18084 | 2013-12-04 20:05:01 | 2013-12-04 20:06:34 | 29ba002bf039bb6439357a10134407de |
54+
* | SELECT `e` . `round_robin_bin` ... `timestamp` = `maxes` . `ts` | mem | * | 8 | 0 | 0 | 17.89 s | 4.12 s | 2.24 s | 7 | 1 | 169534 | 21192 | 2013-12-04 20:04:54 | 2013-12-04 20:05:05 | 0b1c1f91e7e9e0ff91aa49d15f540793 |
55+
* | SELECT `e` . `round_robin_bin` ... `timestamp` = `maxes` . `ts` | mem | * | 1 | 0 | 0 | 2.22 s | 2.22 s | 2.22 s | 1 | 1 | 40322 | 40322 | 2013-12-04 20:05:39 | 2013-12-04 20:05:39 | 07b27145c8f8a3779737df5032374833 |
56+
* | SELECT `e` . `round_robin_bin` ... `timestamp` = `maxes` . `ts` | mem | * | 1 | 0 | 0 | 1.97 s | 1.97 s | 1.97 s | 1 | 1 | 40322 | 40322 | 2013-12-04 20:05:39 | 2013-12-04 20:05:39 | a07488137ea5c1bccf3e291c50bfd21f |
57+
* | SELECT `e` . `round_robin_bin` ... `timestamp` = `maxes` . `ts` | mem | * | 2 | 0 | 0 | 3.91 s | 3.91 s | 1.96 s | 1 | 1 | 13126 | 6563 | 2013-12-04 20:05:04 | 2013-12-04 20:06:34 | b8bddc6566366dafc7e474f67096a93b |
58+
* +-------------------------------------------------------------------+------+-----------+------------+-----------+------------+---------------+-------------+-------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
59+
* 5 rows in set (1.58 sec)
6760
*
68-
* (Example from 5.6.6)
61+
* (Example from 5.6.14)
6962
*
70-
* Versions: 5.6.5+
63+
* Versions: 5.6.9+
7164
*
7265
*/
7366

7467
DROP VIEW IF EXISTS statements_with_runtimes_in_95th_percentile;
7568

7669
CREATE SQL SECURITY INVOKER VIEW statements_with_runtimes_in_95th_percentile AS
7770
SELECT format_statement(DIGEST_TEXT) AS query,
71+
SCHEMA_NAME as db,
7872
IF(SUM_NO_GOOD_INDEX_USED > 0 OR SUM_NO_INDEX_USED > 0, '*', '') AS full_scan,
7973
COUNT_STAR AS exec_count,
8074
SUM_ERRORS AS err_count,
@@ -84,7 +78,10 @@ SELECT format_statement(DIGEST_TEXT) AS query,
8478
format_time(AVG_TIMER_WAIT) AS avg_latency,
8579
SUM_ROWS_SENT AS rows_sent,
8680
ROUND(SUM_ROWS_SENT / COUNT_STAR) AS rows_sent_avg,
87-
SUM_ROWS_EXAMINED AS rows_scanned,
81+
SUM_ROWS_EXAMINED AS rows_examined,
82+
ROUND(SUM_ROWS_EXAMINED / COUNT_STAR) AS rows_examined_avg,
83+
FIRST_SEEN AS first_seen,
84+
LAST_SEEN AS last_seen,
8885
DIGEST AS digest
8986
FROM performance_schema.events_statements_summary_by_digest stmts
9087
JOIN _digest_95th_percentile_by_avg_us AS top_percentile
@@ -95,26 +92,29 @@ SELECT format_statement(DIGEST_TEXT) AS query,
9592
* View: statements_with_runtimes_in_95th_percentile_raw
9693
*
9794
* List all statements who's average runtime, in microseconds, is in the top 95th percentile.
98-
*
95+
*
9996
* mysql> SELECT * FROM statements_with_runtimes_in_95th_percentile_raw LIMIT 1\G
10097
* *************************** 1. row ***************************
101-
* query: SELECT * FROM `top_tables_by_latency` SELECT `performance_schema` . `objects_summary_global_by_type` . `OBJECT_SCHEMA` AS `db_name` , ...
102-
* full_scan: *
103-
* exec_count: 2
104-
* err_count: 0
105-
* warn_count: 0
106-
* total_latency: 30075208207000
107-
* max_latency: 28827579292000
108-
* avg_latency: 15037604103000
109-
* rows_sent: 220
110-
* rows_sent_avg: 110
111-
* rows_scanned: 440
112-
* digest: 44f1f3181975504b160c57b89c9ce23e
113-
* 1 row in set (0.36 sec)
98+
* query: SELECT `e` . `round_robin_bin` AS `round1_1706_0_` , `e` . `id` AS `id1706_0_` , `e` . `timestamp` AS `timestamp1706_0_` , `e` . `rxBytes` AS `rxBytes1706_0_` , `e` . `rxPackets` AS `rxPackets1706_0_` , `e` . `rxErrors` AS `rxErrors1706_0_` , `e` . `txBytes` AS `txBytes1706_0_` , `e` . `txPackets` AS `txPackets1706_0_` , `e` . `txErrors` AS `txErrors1706_0_` , `e` . `txCollisions` AS `txColli10_1706_0_` FROM `mem__instruments` . `NetworkTrafficAdvisor_NetworkTraffic` AS `e` JOIN ( SELECT `id` AS `t` , MAX ( TIMESTAMP ) AS `ts` FROM `mem__instruments` . `NetworkTrafficAdvisor_NetworkTraffic` WHERE `id` IN (?) GROUP BY `id` ORDER BY NULL ) `maxes` ON `e` . `id` = `maxes` . `t` AND `e` . `timestamp` = `maxes` . `ts`
99+
* full_scan: *
100+
* exec_count: 14
101+
* err_count: 0
102+
* warn_count: 0
103+
* total_latency: 43961670267000
104+
* max_latency: 6686877140000
105+
* avg_latency: 3140119304000
106+
* rows_sent: 11
107+
* rows_sent_avg: 1
108+
* rows_examined: 253170
109+
* rows_examined_avg: 18084
110+
* first_seen: 2013-12-04 20:05:01
111+
* last_seen: 2013-12-04 20:06:34
112+
* digest: 29ba002bf039bb6439357a10134407de
113+
* 1 row in set (1.50 sec)
114114
*
115-
* (Example from 5.6.6)
115+
* (Example from 5.6.14)
116116
*
117-
* Versions: 5.6.5+
117+
* Versions: 5.6.9+
118118
*
119119
*/
120120

@@ -131,9 +131,12 @@ SELECT DIGEST_TEXT AS query,
131131
AVG_TIMER_WAIT AS avg_latency,
132132
SUM_ROWS_SENT AS rows_sent,
133133
ROUND(SUM_ROWS_SENT / COUNT_STAR) AS rows_sent_avg,
134-
SUM_ROWS_EXAMINED AS rows_scanned,
134+
SUM_ROWS_EXAMINED AS rows_examined,
135+
ROUND(SUM_ROWS_EXAMINED / COUNT_STAR) AS rows_examined_avg,
136+
FIRST_SEEN as first_seen,
137+
LAST_SEEN as last_seen,
135138
DIGEST AS digest
136139
FROM performance_schema.events_statements_summary_by_digest stmts
137140
JOIN _digest_95th_percentile_by_avg_us AS top_percentile
138141
ON ROUND(stmts.avg_timer_wait/1000000) >= top_percentile.avg_us
139-
ORDER BY AVG_TIMER_WAIT DESC;
142+
ORDER BY AVG_TIMER_WAIT DESC;

0 commit comments

Comments
 (0)