Skip to content

Commit b1cd5ca

Browse files
committed
Import innodb.virtual_stats from MySQL 5.7
1 parent e9bc0f7 commit b1cd5ca

File tree

2 files changed

+179
-0
lines changed

2 files changed

+179
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
CREATE TABLE t (
2+
a INT,
3+
b INT,
4+
c INT GENERATED ALWAYS AS(a+b),
5+
d INT GENERATED ALWAYS AS(a+b+b),
6+
KEY idxa (a),
7+
KEY vidxcd (c, d)
8+
) ENGINE=INNODB;
9+
INSERT INTO t (a,b) VALUES (1, 2);
10+
SELECT index_name, stat_name, stat_description
11+
FROM mysql.innodb_index_stats
12+
WHERE database_name = 'test' AND table_name = 't';
13+
index_name stat_name stat_description
14+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
15+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
16+
GEN_CLUST_INDEX size Number of pages in the index
17+
idxa n_diff_pfx01 a
18+
idxa n_diff_pfx02 a,DB_ROW_ID
19+
idxa n_leaf_pages Number of leaf pages in the index
20+
idxa size Number of pages in the index
21+
vidxcd n_diff_pfx01 c
22+
vidxcd n_diff_pfx02 c,d
23+
vidxcd n_diff_pfx03 c,d,DB_ROW_ID
24+
vidxcd n_leaf_pages Number of leaf pages in the index
25+
vidxcd size Number of pages in the index
26+
ALTER TABLE t ADD COLUMN e INT GENERATED ALWAYS AS(a+a+b), ADD INDEX idxb (b), ALGORITHM=INPLACE;
27+
SELECT index_name, stat_name, stat_description
28+
FROM mysql.innodb_index_stats
29+
WHERE database_name = 'test' AND table_name = 't';
30+
index_name stat_name stat_description
31+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
32+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
33+
GEN_CLUST_INDEX size Number of pages in the index
34+
idxa n_diff_pfx01 a
35+
idxa n_diff_pfx02 a,DB_ROW_ID
36+
idxa n_leaf_pages Number of leaf pages in the index
37+
idxa size Number of pages in the index
38+
idxb n_diff_pfx01 b
39+
idxb n_diff_pfx02 b,DB_ROW_ID
40+
idxb n_leaf_pages Number of leaf pages in the index
41+
idxb size Number of pages in the index
42+
vidxcd n_diff_pfx01 c
43+
vidxcd n_diff_pfx02 c,d
44+
vidxcd n_diff_pfx03 c,d,DB_ROW_ID
45+
vidxcd n_leaf_pages Number of leaf pages in the index
46+
vidxcd size Number of pages in the index
47+
ALTER TABLE t DROP COLUMN c, DROP INDEX idxa, ALGORITHM=INPLACE;
48+
SELECT index_name, stat_name, stat_description
49+
FROM mysql.innodb_index_stats
50+
WHERE database_name = 'test' AND table_name = 't';
51+
index_name stat_name stat_description
52+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
53+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
54+
GEN_CLUST_INDEX size Number of pages in the index
55+
idxb n_diff_pfx01 b
56+
idxb n_diff_pfx02 b,DB_ROW_ID
57+
idxb n_leaf_pages Number of leaf pages in the index
58+
idxb size Number of pages in the index
59+
vidxcd n_diff_pfx01 d
60+
vidxcd n_diff_pfx02 d,DB_ROW_ID
61+
vidxcd n_leaf_pages Number of leaf pages in the index
62+
vidxcd size Number of pages in the index
63+
ALTER TABLE t ADD INDEX vidxe (e), ALGORITHM=INPLACE;
64+
SELECT index_name, stat_name, stat_description
65+
FROM mysql.innodb_index_stats
66+
WHERE database_name = 'test' AND table_name = 't';
67+
index_name stat_name stat_description
68+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
69+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
70+
GEN_CLUST_INDEX size Number of pages in the index
71+
idxb n_diff_pfx01 b
72+
idxb n_diff_pfx02 b,DB_ROW_ID
73+
idxb n_leaf_pages Number of leaf pages in the index
74+
idxb size Number of pages in the index
75+
vidxcd n_diff_pfx01 d
76+
vidxcd n_diff_pfx02 d,DB_ROW_ID
77+
vidxcd n_leaf_pages Number of leaf pages in the index
78+
vidxcd size Number of pages in the index
79+
vidxe n_diff_pfx01 e
80+
vidxe n_diff_pfx02 e,DB_ROW_ID
81+
vidxe n_leaf_pages Number of leaf pages in the index
82+
vidxe size Number of pages in the index
83+
ALTER TABLE t ADD COLUMN f INT GENERATED ALWAYS AS(a + a), ADD INDEX vidxf (f), ALGORITHM=INPLACE;
84+
SELECT index_name, stat_name, stat_description
85+
FROM mysql.innodb_index_stats
86+
WHERE database_name = 'test' AND table_name = 't';
87+
index_name stat_name stat_description
88+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
89+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
90+
GEN_CLUST_INDEX size Number of pages in the index
91+
idxb n_diff_pfx01 b
92+
idxb n_diff_pfx02 b,DB_ROW_ID
93+
idxb n_leaf_pages Number of leaf pages in the index
94+
idxb size Number of pages in the index
95+
vidxcd n_diff_pfx01 d
96+
vidxcd n_diff_pfx02 d,DB_ROW_ID
97+
vidxcd n_leaf_pages Number of leaf pages in the index
98+
vidxcd size Number of pages in the index
99+
vidxe n_diff_pfx01 e
100+
vidxe n_diff_pfx02 e,DB_ROW_ID
101+
vidxe n_leaf_pages Number of leaf pages in the index
102+
vidxe size Number of pages in the index
103+
vidxf n_diff_pfx01 f
104+
vidxf n_diff_pfx02 f,DB_ROW_ID
105+
vidxf n_leaf_pages Number of leaf pages in the index
106+
vidxf size Number of pages in the index
107+
ALTER TABLE t DROP INDEX vidxcd;
108+
SELECT index_name, stat_name, stat_description
109+
FROM mysql.innodb_index_stats
110+
WHERE database_name = 'test' AND table_name = 't';
111+
index_name stat_name stat_description
112+
GEN_CLUST_INDEX n_diff_pfx01 DB_ROW_ID
113+
GEN_CLUST_INDEX n_leaf_pages Number of leaf pages in the index
114+
GEN_CLUST_INDEX size Number of pages in the index
115+
idxb n_diff_pfx01 b
116+
idxb n_diff_pfx02 b,DB_ROW_ID
117+
idxb n_leaf_pages Number of leaf pages in the index
118+
idxb size Number of pages in the index
119+
vidxe n_diff_pfx01 e
120+
vidxe n_diff_pfx02 e,DB_ROW_ID
121+
vidxe n_leaf_pages Number of leaf pages in the index
122+
vidxe size Number of pages in the index
123+
vidxf n_diff_pfx01 f
124+
vidxf n_diff_pfx02 f,DB_ROW_ID
125+
vidxf n_leaf_pages Number of leaf pages in the index
126+
vidxf size Number of pages in the index
127+
DROP TABLE t;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--source include/have_innodb.inc
2+
3+
#
4+
# BUG#22469660 INNODB DOESN'T UPDATE INDEX STATS WHEN ADDING OR DROPPING VIRTUAL COLUMN
5+
#
6+
7+
CREATE TABLE t (
8+
a INT,
9+
b INT,
10+
c INT GENERATED ALWAYS AS(a+b),
11+
d INT GENERATED ALWAYS AS(a+b+b),
12+
KEY idxa (a),
13+
KEY vidxcd (c, d)
14+
) ENGINE=INNODB;
15+
16+
INSERT INTO t (a,b) VALUES (1, 2);
17+
18+
SELECT index_name, stat_name, stat_description
19+
FROM mysql.innodb_index_stats
20+
WHERE database_name = 'test' AND table_name = 't';
21+
22+
ALTER TABLE t ADD COLUMN e INT GENERATED ALWAYS AS(a+a+b), ADD INDEX idxb (b), ALGORITHM=INPLACE;
23+
24+
SELECT index_name, stat_name, stat_description
25+
FROM mysql.innodb_index_stats
26+
WHERE database_name = 'test' AND table_name = 't';
27+
28+
ALTER TABLE t DROP COLUMN c, DROP INDEX idxa, ALGORITHM=INPLACE;
29+
30+
SELECT index_name, stat_name, stat_description
31+
FROM mysql.innodb_index_stats
32+
WHERE database_name = 'test' AND table_name = 't';
33+
34+
ALTER TABLE t ADD INDEX vidxe (e), ALGORITHM=INPLACE;
35+
36+
SELECT index_name, stat_name, stat_description
37+
FROM mysql.innodb_index_stats
38+
WHERE database_name = 'test' AND table_name = 't';
39+
40+
ALTER TABLE t ADD COLUMN f INT GENERATED ALWAYS AS(a + a), ADD INDEX vidxf (f), ALGORITHM=INPLACE;
41+
42+
SELECT index_name, stat_name, stat_description
43+
FROM mysql.innodb_index_stats
44+
WHERE database_name = 'test' AND table_name = 't';
45+
46+
ALTER TABLE t DROP INDEX vidxcd;
47+
48+
SELECT index_name, stat_name, stat_description
49+
FROM mysql.innodb_index_stats
50+
WHERE database_name = 'test' AND table_name = 't';
51+
52+
DROP TABLE t;

0 commit comments

Comments
 (0)