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
3939VIEW schema_tables_with_full_table_scans (
4040 object_schema,
4141 object_name,
42- rows_full_scanned
42+ rows_full_scanned,
43+ latency
4344) AS
4445SELECT 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