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

Commit 6e0d952

Browse files
committed
Added a test for the schema_tables_with_full_table_scans view, to try and reproduce Issue #8 (and it could not be reproduced).
1 parent 392a956 commit 6e0d952

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
DESC sys.schema_tables_with_full_table_scans;
2+
Field Type Null Key Default Extra
3+
object_schema varchar(64) YES NULL
4+
object_name varchar(64) YES NULL
5+
rows_full_scanned bigint(20) unsigned NO NULL
6+
latency text YES NULL
7+
DESC sys.x$schema_tables_with_full_table_scans;
8+
Field Type Null Key Default Extra
9+
object_schema varchar(64) YES NULL
10+
object_name varchar(64) YES NULL
11+
rows_full_scanned bigint(20) unsigned NO NULL
12+
latency bigint(20) unsigned NO NULL
13+
CREATE DATABASE v_schema_tables_with_full_table_scans;
14+
CREATE TABLE v_schema_tables_with_full_table_scans.t (i BIGINT AUTO_INCREMENT PRIMARY KEY, j BIGINT) ENGINE = innodb;
15+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) VALUES (1), (2), (3);
16+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
17+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
18+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
19+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
20+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
21+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
22+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
23+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
24+
CALL sys.ps_truncate_all_tables(false);
25+
summary
26+
Truncated 44 tables
27+
SELECT * FROM v_schema_tables_with_full_table_scans.t WHERE j = 12;
28+
i j
29+
12 12
30+
19 12
31+
22 12
32+
34 12
33+
37 12
34+
43 12
35+
65 12
36+
68 12
37+
74 12
38+
86 12
39+
128 12
40+
131 12
41+
137 12
42+
149 12
43+
173 12
44+
255 12
45+
258 12
46+
264 12
47+
276 12
48+
300 12
49+
348 12
50+
510 12
51+
513 12
52+
519 12
53+
531 12
54+
555 12
55+
603 12
56+
699 12
57+
SELECT object_schema, object_name, rows_full_scanned FROM sys.schema_tables_with_full_table_scans;
58+
object_schema object_name rows_full_scanned
59+
v_schema_tables_with_full_table_scans t 768
60+
SELECT object_schema, object_name, rows_full_scanned FROM sys.x$schema_tables_with_full_table_scans;
61+
object_schema object_name rows_full_scanned
62+
v_schema_tables_with_full_table_scans t 768
63+
DROP DATABASE v_schema_tables_with_full_table_scans;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Tests for sys schema
2+
# Verify the sys.schema_tables_with_full_table_scans/sys.x$schema_tables_with_full_table_scans views
3+
4+
DESC sys.schema_tables_with_full_table_scans;
5+
6+
DESC sys.x$schema_tables_with_full_table_scans;
7+
8+
# Create a dummy table, force some full table scans, verify the results
9+
CREATE DATABASE v_schema_tables_with_full_table_scans;
10+
11+
CREATE TABLE v_schema_tables_with_full_table_scans.t (i BIGINT AUTO_INCREMENT PRIMARY KEY, j BIGINT) ENGINE = innodb;
12+
13+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) VALUES (1), (2), (3);
14+
15+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
16+
17+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
18+
19+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
20+
21+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
22+
23+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
24+
25+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
26+
27+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
28+
29+
INSERT INTO v_schema_tables_with_full_table_scans.t (j) (SELECT j*2 FROM v_schema_tables_with_full_table_scans.t);
30+
31+
# The table should now have 768 rows
32+
33+
# Now truncate the P_S tables, to get fresh results
34+
CALL sys.ps_truncate_all_tables(false);
35+
36+
# Following returns 28 rows, but should full scan as j has no index
37+
SELECT * FROM v_schema_tables_with_full_table_scans.t WHERE j = 12;
38+
39+
# Now verify the table shows up in the views with the right row count
40+
SELECT object_schema, object_name, rows_full_scanned FROM sys.schema_tables_with_full_table_scans;
41+
42+
SELECT object_schema, object_name, rows_full_scanned FROM sys.x$schema_tables_with_full_table_scans;
43+
44+
# Cleanup
45+
DROP DATABASE v_schema_tables_with_full_table_scans;

0 commit comments

Comments
 (0)