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

Commit 5f47671

Browse files
committed
Add latency stats to the schema_tables_with_full_table_scans view, also add an x$ counterpart
1 parent 163cdf3 commit 5f47671

File tree

2 files changed

+61
-21
lines changed

2 files changed

+61
-21
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ innodb_buffer_bytes_allocated: 311296
560560
innodb_buffer_rows_cached: 2
561561
```
562562

563-
#### schema_tables_with_full_table_scans
563+
#### schema_tables_with_full_table_scans / x$schema_tables_with_full_table_scans
564564

565565
##### Description
566566

@@ -570,15 +570,15 @@ Finds tables that are being accessed by full table scans ordering by the number
570570

571571
```SQL
572572
mysql> select * from schema_tables_with_full_table_scans limit 5;
573-
+------------------+-------------------+-------------------+
574-
| object_schema | object_name | rows_full_scanned |
575-
+------------------+-------------------+-------------------+
576-
| mem | rule_alarms | 1210 |
577-
| mem30__advisors | advisor_schedules | 1021 |
578-
| mem30__inventory | agent | 498 |
579-
| mem | dc_p_string | 449 |
580-
| mem30__inventory | mysqlserver | 294 |
581-
+------------------+-------------------+-------------------+
573+
+--------------------+--------------------------------+-------------------+-----------+
574+
| object_schema | object_name | rows_full_scanned | latency |
575+
+--------------------+--------------------------------+-------------------+-----------+
576+
| mem30__instruments | fsstatistics | 10207042 | 13.10 s |
577+
| mem30__instruments | preparedstatementapidata | 436428 | 973.27 ms |
578+
| mem30__instruments | mysqlprocessactivity | 411702 | 282.07 ms |
579+
| mem30__instruments | querycachequeriesincachedata | 374011 | 767.15 ms |
580+
| mem30__instruments | rowaccessesdata | 322321 | 1.55 s |
581+
+--------------------+--------------------------------+-------------------+-----------+
582582
```
583583

584584
#### schema_unused_indexes

views/p_s/schema_tables_with_full_table_scans.sql

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
* ordering by the number of rows scanned descending.
2121
*
2222
* mysql> select * from schema_tables_with_full_table_scans limit 5;
23-
* +------------------+-------------------+-------------------+
24-
* | object_schema | object_name | rows_full_scanned |
25-
* +------------------+-------------------+-------------------+
26-
* | mem | rule_alarms | 1210 |
27-
* | mem30__advisors | advisor_schedules | 1021 |
28-
* | mem30__inventory | agent | 498 |
29-
* | mem | dc_p_string | 449 |
30-
* | mem30__inventory | mysqlserver | 294 |
31-
* +------------------+-------------------+-------------------+
23+
* +--------------------+--------------------------------+-------------------+-----------+
24+
* | object_schema | object_name | rows_full_scanned | latency |
25+
* +--------------------+--------------------------------+-------------------+-----------+
26+
* | mem30__instruments | fsstatistics | 10207042 | 13.10 s |
27+
* | mem30__instruments | preparedstatementapidata | 436428 | 973.27 ms |
28+
* | mem30__instruments | mysqlprocessactivity | 411702 | 282.07 ms |
29+
* | mem30__instruments | querycachequeriesincachedata | 374011 | 767.15 ms |
30+
* | mem30__instruments | rowaccessesdata | 322321 | 1.55 s |
31+
* +--------------------+--------------------------------+-------------------+-----------+
3232
*
3333
*/
3434

@@ -39,11 +39,51 @@ CREATE OR REPLACE
3939
VIEW schema_tables_with_full_table_scans (
4040
object_schema,
4141
object_name,
42-
rows_full_scanned
42+
rows_full_scanned,
43+
latency
4344
) AS
4445
SELECT object_schema,
4546
object_name,
46-
count_read AS rows_full_scanned
47+
count_read AS rows_full_scanned,
48+
sys.format_time(sum_timer_wait) AS latency
49+
FROM performance_schema.table_io_waits_summary_by_index_usage
50+
WHERE index_name IS NULL
51+
AND count_read > 0
52+
ORDER BY count_read DESC;
53+
54+
/*
55+
* View: x$schema_tables_with_full_table_scans
56+
*
57+
* Find tables that are being accessed by full table scans
58+
* ordering by the number of rows scanned descending.
59+
*
60+
* mysql> select * from x$schema_tables_with_full_table_scans limit 5;
61+
* +--------------------+------------------------------+-------------------+----------------+
62+
* | object_schema | object_name | rows_full_scanned | latency |
63+
* +--------------------+------------------------------+-------------------+----------------+
64+
* | mem30__instruments | fsstatistics | 10207042 | 13098927688488 |
65+
* | mem30__instruments | preparedstatementapidata | 436428 | 973274338980 |
66+
* | mem30__instruments | mysqlprocessactivity | 411702 | 282072434940 |
67+
* | mem30__instruments | querycachequeriesincachedata | 374011 | 767152380564 |
68+
* | mem30__instruments | rowaccessesdata | 322321 | 1547594778456 |
69+
* +--------------------+------------------------------+-------------------+----------------+
70+
*
71+
*/
72+
73+
CREATE OR REPLACE
74+
ALGORITHM = MERGE
75+
DEFINER = 'root'@'localhost'
76+
SQL SECURITY INVOKER
77+
VIEW x$schema_tables_with_full_table_scans (
78+
object_schema,
79+
object_name,
80+
rows_full_scanned,
81+
latency
82+
) AS
83+
SELECT object_schema,
84+
object_name,
85+
count_read AS rows_full_scanned,
86+
sum_timer_wait AS latency
4787
FROM performance_schema.table_io_waits_summary_by_index_usage
4888
WHERE index_name IS NULL
4989
AND count_read > 0

0 commit comments

Comments
 (0)