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

Commit 500b9bf

Browse files
committed
Merge pull request #6 from aadant/master
Merge changes from Arnaud Adant to add schema to statement views, as well as first and last seen, and a couple of extra stats.
2 parents ded6871 + c12e666 commit 500b9bf

6 files changed

+148
-118
lines changed

views/p_s/statement_analysis.sql

Lines changed: 37 additions & 29 deletions
Large diffs are not rendered by default.

views/p_s/statements_with_errors_or_warnings.sql

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,36 @@
33
*
44
* List all normalized statements that have raised errors or warnings.
55
*
6-
* mysql> select * from statements_with_errors_or_warnings;
7-
* +-------------------------------------------------------------------+------------+--------+-----------+----------+-------------+----------------------------------+
8-
* | query | exec_count | errors | error_pct | warnings | warning_pct | digest |
9-
* +-------------------------------------------------------------------+------------+--------+-----------+----------+-------------+----------------------------------+
10-
* | CREATE PROCEDURE currently_ena ... w_instruments BOOLEAN DEFAULT | 2 | 2 | 100.0000 | 0 | 0.0000 | ad6024cfc2db562ae268b25e65ef27c0 |
11-
* | CREATE PROCEDURE currently_ena ... ents WHERE enabled = ? ; END | 2 | 1 | 50.0000 | 0 | 0.0000 | 4aac3ab9521a432ff03313a69cfcc58f |
12-
* | CREATE PROCEDURE currently_enabled ( BOOLEAN show_instruments | 1 | 1 | 100.0000 | 0 | 0.0000 | c6df6711da3d1a26bc136dc8b354f6eb |
13-
* | CREATE PROCEDURE disable_backg ... d = ? WHERE TYPE = ? ; END IF | 1 | 1 | 100.0000 | 0 | 0.0000 | 12e0392402780424c736c9555bcc9703 |
14-
* | DROP PROCEDURE IF EXISTS currently_enabled | 12 | 0 | 0.0000 | 6 | 50.0000 | 44cc7e655d08f430e0dd8f3110ed816c |
15-
* | DROP PROCEDURE IF EXISTS disable_background_threads | 3 | 0 | 0.0000 | 2 | 66.6667 | 0153b7158dae80672bda6181c73f172c |
16-
* | CREATE SCHEMA IF NOT EXISTS ps_helper | 2 | 0 | 0.0000 | 1 | 50.0000 | a12cabd32d1507c758c71478075f5290 |
17-
* +-------------------------------------------------------------------+------------+--------+-----------+----------+-------------+----------------------------------+
18-
*
19-
* Versions 5.6.5+
6+
* mysql> select * from statements_with_errors_or_warnings limit 5;
7+
* +-------------------------------------------------------------------+-----------+------------+--------+-----------+----------+-------------+---------------------+---------------------+----------------------------------+
8+
* | query | db | exec_count | errors | error_pct | warnings | warning_pct | first_seen | last_seen | digest |
9+
* +-------------------------------------------------------------------+-----------+------------+--------+-----------+----------+-------------+---------------------+---------------------+----------------------------------+
10+
* | INSERT INTO `mem__quan` . `nor ... `lastSeen` ) ) , `lastSeen` ) | mem | 7619897 | 645 | 0.0085 | 0 | 0.0000 | 2013-12-04 20:05:34 | 2013-12-18 18:48:34 | 6134e9d6f25eb8e6cddf11f6938f202a |
11+
* | INSERT INTO `mem__inventory` . ... , `Filesystem` ) VALUES (...) | mem | 54 | 3 | 5.5556 | 0 | 0.0000 | 2013-12-04 20:10:22 | 2013-12-18 18:48:44 | e225410633e09d7c6288cc390654b361 |
12+
* | INSERT INTO `mem__events` . `e ... ?, ... , (_charset) ?, ... ) | mem | 521 | 3 | 0.5758 | 0 | 0.0000 | 2013-12-04 20:04:53 | 2013-12-18 18:05:34 | 9b9714753319e42ffb3483377c1e596c |
13+
* | CREATE SQL SECURITY INVOKER VI ... CREATED_T` `SUM_SORT_ROWS` AS | ps_helper | 2 | 2 | 100.0000 | 0 | 0.0000 | 2013-12-18 17:46:28 | 2013-12-18 17:46:32 | 7131bbf490c4b7bdc93dd76599084996 |
14+
* | SELECT `mysqlconne0_` . `hid` ... ` AS `hasProc18_1821_0_` , ... | mem | 982158 | 1 | 0.0001 | 0 | 0.0000 | 2013-12-04 20:04:48 | 2013-12-18 18:49:04 | 24259bc30a8f8b0b53ba0283d940f938 |
15+
* +-------------------------------------------------------------------+-----------+------------+--------+-----------+----------+-------------+---------------------+---------------------+----------------------------------+
16+
* 5 rows in set (0.02 sec)
17+
*
18+
* (Example from 5.6.14)
19+
*
20+
* Versions 5.6.9+
2021
*
2122
*/
2223

2324
DROP VIEW IF EXISTS statements_with_errors_or_warnings;
2425

2526
CREATE SQL SECURITY INVOKER VIEW statements_with_errors_or_warnings AS
2627
SELECT format_statement(DIGEST_TEXT) AS query,
28+
SCHEMA_NAME as db,
2729
COUNT_STAR AS exec_count,
2830
SUM_ERRORS AS errors,
2931
(SUM_ERRORS / COUNT_STAR) * 100 as error_pct,
3032
SUM_WARNINGS AS warnings,
3133
(SUM_WARNINGS / COUNT_STAR) * 100 as warning_pct,
34+
FIRST_SEEN as first_seen,
35+
LAST_SEEN as last_seen,
3236
DIGEST AS digest
3337
FROM performance_schema.events_statements_summary_by_digest
3438
WHERE SUM_ERRORS > 0

views/p_s/statements_with_full_table_scans.sql

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@
66
* then by the number of times the statement executed
77
*
88
* mysql> select * from statements_with_full_table_scans limit 5;
9-
* +-------------------------------------------------------------------+------------+---------------------+--------------------------+-------------------+-----------+---------------+----------------------------------+
10-
* | query | exec_count | no_index_used_count | no_good_index_used_count | no_index_used_pct | rows_sent | rows_examined | digest |
11-
* +-------------------------------------------------------------------+------------+---------------------+--------------------------+-------------------+-----------+---------------+----------------------------------+
12-
* | SELECT DISTINCTROW `agent0_` . ... ERE `agent0_` . `id` IN (...) | 1474 | 1474 | 0 | 100 | 2948 | 2948 | 4f5d5cc354ebb4746ccb71d9c750e978 |
13-
* | SELECT COUNT ( * ) FROM `INFOR ... NE = ? AND `SUPPORT` IN (...) | 1228 | 1228 | 0 | 100 | 1228 | 11052 | 491ee7143ca1d98f36c24d7eb6d25272 |
14-
* | SELECT DISTINCTROW `mysqlconne ... conne0_` . `socketPath` AS ... | 1135 | 1132 | 0 | 100 | 5 | 3393 | 15024988ff6ff3510057b48ca2dfd5d3 |
15-
* | SELECT `InterfaceAddress4` . ` ... . `hid` WHERE `Os` . `id` = ? | 1132 | 1132 | 0 | 100 | 7924 | 82588 | 42d79211cc5e82e32e00340bc6a50b14 |
16-
* | SELECT COUNT ( * ) FROM `infor ... NAME = ? AND `index_name` = ? | 772 | 772 | 0 | 100 | 772 | 3301 | c8a721d366327a8170d4260fe789941a |
17-
* +-------------------------------------------------------------------+------------+---------------------+--------------------------+-------------------+-----------+---------------+----------------------------------+
18-
* 5 rows in set (0.03 sec) *
9+
* +-------------------------------------------------------------------+-------+------------+---------------------+--------------------------+-------------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
10+
* | query | db | exec_count | no_index_used_count | no_good_index_used_count | no_index_used_pct | rows_sent | rows_examined | rows_sent_avg | rows_examined_avg | first_seen | last_seen | digest |
11+
* +-------------------------------------------------------------------+-------+------------+---------------------+--------------------------+-------------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
12+
* | SELECT `InterfaceAddress4` . ` ... . `hid` WHERE `Os` . `id` = ? | mem | 355189 | 355277 | 0 | 100 | 404862 | 4987778 | 1 | 14 | 2013-12-04 20:04:54 | 2013-12-18 18:54:34 | 42d79211cc5e82e32e00340bc6a50b14 |
13+
* | SELECT COUNT ( * ) FROM `INFOR ... NE = ? AND `SUPPORT` IN (...) | mysql | 172765 | 172776 | 0 | 100 | 172773 | 1554966 | 1 | 9 | 2013-12-04 20:04:52 | 2013-12-18 18:54:34 | 491ee7143ca1d98f36c24d7eb6d25272 |
14+
* | SELECT CAST ( `SUM_NUMBER_OF_B ... HERE `EVENT_NAME` = ? LIMIT ? | mysql | 100455 | 100455 | 0 | 100 | 100455 | 3094014 | 1 | 31 | 2013-12-04 20:04:52 | 2013-12-18 18:54:34 | b5a370d80095c69a2085547e3a24f552 |
15+
* | SELECT COUNT ( * ) FROM `INFOR ... CHEMA` = ? AND TABLE_NAME = ? | mysql | 80360 | 80360 | 0 | 100 | 80360 | 0 | 1 | 0 | 2013-12-04 20:05:37 | 2013-12-18 18:54:34 | 6567aa2ac8ad7fe7831b4114dee7c849 |
16+
* | SELECT DISTINCTROW `mysqlconne ... conne0_` . `socketPath` AS ... | mem | 67832 | 67821 | 0 | 100 | 92 | 406943 | 0 | 6 | 2013-12-04 20:04:54 | 2013-12-18 18:54:34 | fc358ad6384cc77adff425602a0a8fc1 |
17+
* +-------------------------------------------------------------------+-------+------------+---------------------+--------------------------+-------------------+-----------+---------------+---------------+-------------------+---------------------+---------------------+----------------------------------+
18+
* 5 rows in set (0.02 sec)
1919
*
20-
* (Example from 5.6.6)
20+
* (Example from 5.6.14)
2121
*
22-
* Versions: 5.6.5+
22+
* Versions: 5.6.9+
2323
*
2424
*/
2525

2626
DROP VIEW IF EXISTS statements_with_full_table_scans;
2727

2828
CREATE SQL SECURITY INVOKER VIEW statements_with_full_table_scans AS
2929
SELECT ps_helper.format_statement(DIGEST_TEXT) AS query,
30+
SCHEMA_NAME as db,
3031
COUNT_STAR AS exec_count,
3132
SUM_NO_INDEX_USED AS no_index_used_count,
3233
SUM_NO_GOOD_INDEX_USED AS no_good_index_used_count,
3334
ROUND((SUM_NO_INDEX_USED / COUNT_STAR) * 100) AS no_index_used_pct,
3435
SUM_ROWS_SENT AS rows_sent,
3536
SUM_ROWS_EXAMINED AS rows_examined,
37+
ROUND(SUM_ROWS_SENT/COUNT_STAR) AS rows_sent_avg,
38+
ROUND(SUM_ROWS_EXAMINED/COUNT_STAR) AS rows_examined_avg,
39+
FIRST_SEEN as first_seen,
40+
LAST_SEEN as last_seen,
3641
DIGEST AS digest
3742
FROM performance_schema.events_statements_summary_by_digest
3843
WHERE SUM_NO_INDEX_USED > 0

0 commit comments

Comments
 (0)