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

Commit 960d0a7

Browse files
committed
Ignore SHOW statements within the statements_with_full_table_scans views, they will always do a full table scan, and there is nothing an administrator can do about it
1 parent c6ae129 commit 960d0a7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ warning_pct: 0.0000
671671

672672
Lists all normalized statements that use have done a full table scan ordered by number the percentage of times a full scan was done, then by the statement latency.
673673

674+
This view ignores SHOW statements, as these always cause a full table scan, and there is nothing that can be done about this.
675+
674676
##### Example
675677

676678
```SQL

views/p_s/statements_with_full_table_scans.sql

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
* ordered by number the percentage of times a full scan was done,
2121
* then by the statement latency.
2222
*
23+
* This view ignores SHOW statements, as these always cause a full table scan,
24+
* and there is nothing that can be done about this.
25+
*
2326
* mysql> select * from statements_with_full_table_scans limit 1\G
2427
* *************************** 1. row ***************************
2528
* query: SELECT * FROM `schema_tables_w ... ex_usage` . `COUNT_READ` DESC
@@ -74,8 +77,9 @@ SELECT sys.format_statement(DIGEST_TEXT) AS query,
7477
LAST_SEEN as last_seen,
7578
DIGEST AS digest
7679
FROM performance_schema.events_statements_summary_by_digest
77-
WHERE SUM_NO_INDEX_USED > 0
78-
OR SUM_NO_GOOD_INDEX_USED > 0
80+
WHERE (SUM_NO_INDEX_USED > 0
81+
OR SUM_NO_GOOD_INDEX_USED > 0)
82+
AND DIGEST_TEXT NOT LIKE 'SHOW%'
7983
ORDER BY no_index_used_pct DESC, total_latency DESC;
8084

8185
/*
@@ -85,6 +89,9 @@ SELECT sys.format_statement(DIGEST_TEXT) AS query,
8589
* ordered by number the percentage of times a full scan was done,
8690
* then by the statement latency.
8791
*
92+
* This view ignores SHOW statements, as these always cause a full table scan,
93+
* and there is nothing that can be done about this.
94+
*
8895
* mysql> select * from x$statements_with_full_table_scans limit 1\G
8996
* *************************** 1. row ***************************
9097
* query: SELECT * FROM `schema_object_overview` SELECT `information_schema` . `routines` . `ROUTINE_SCHEMA` // truncated
@@ -139,6 +146,7 @@ SELECT DIGEST_TEXT AS query,
139146
LAST_SEEN as last_seen,
140147
DIGEST AS digest
141148
FROM performance_schema.events_statements_summary_by_digest
142-
WHERE SUM_NO_INDEX_USED > 0
143-
OR SUM_NO_GOOD_INDEX_USED > 0
149+
WHERE (SUM_NO_INDEX_USED > 0
150+
OR SUM_NO_GOOD_INDEX_USED > 0)
151+
AND DIGEST_TEXT NOT LIKE 'SHOW%'
144152
ORDER BY no_index_used_pct DESC, total_latency DESC;

0 commit comments

Comments
 (0)