Description:
It seems we don't update index stats when dropping a virtual column in a virtual index.
How to repeat:
CREATE TABLE t (
a INT,
b INT,
c INT GENERATED ALWAYS AS(a+b),
d INT GENERATED ALWAYS AS(a+b+b),
KEY vidx (c, d)
)ENGINE=INNODB;
INSERT INTO t (a,b) VALUES (0, 0), (11, NULL);
select * from mysql.innodb_index_stats WHERE database_name = 'test' AND table_name = 't';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 n_diff_pfx01 2 1 DB_ROW_ID
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 n_leaf_pages 1 NULL Number of leaf pages in the index
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 size 1 NULL Number of pages in the index
test t vidx 2015-12-25 13:37:47 n_diff_pfx01 2 1 c
test t vidx 2015-12-25 13:37:47 n_diff_pfx02 2 1 c,d
test t vidx 2015-12-25 13:37:47 n_diff_pfx03 2 1 c,d,DB_ROW_ID
test t vidx 2015-12-25 13:37:47 n_leaf_pages 1 NULL Number of leaf pages in the index
test t vidx 2015-12-25 13:37:47 size 1 NULL Number of pages in the index
ALTER TABLE t DROP COLUMN c, ALGORITHM=INPLACE;
select * from mysql.innodb_index_stats WHERE database_name = 'test' AND table_name = 't';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 n_diff_pfx01 2 1 DB_ROW_ID
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 n_leaf_pages 1 NULL Number of leaf pages in the index
test t GEN_CLUST_INDEX 2015-12-25 13:37:47 size 1 NULL Number of pages in the index
test t vidx 2015-12-25 13:37:47 n_diff_pfx01 2 1 c
test t vidx 2015-12-25 13:37:47 n_diff_pfx02 2 1 c,d
test t vidx 2015-12-25 13:37:47 n_diff_pfx03 2 1 c,d,DB_ROW_ID
test t vidx 2015-12-25 13:37:47 n_leaf_pages 1 NULL Number of leaf pages in the index
test t vidx 2015-12-25 13:37:47 size 1 NULL Number of pages in the index
Correct result for vidx should be like:
select * from mysql.innodb_index_stats WHERE database_name = 'test' AND table_name = 't';
database_name table_name index_name last_update stat_name stat_value sample_size stat_description
test t GEN_CLUST_INDEX 2015-12-25 13:42:18 n_diff_pfx01 2 1 DB_ROW_ID
test t GEN_CLUST_INDEX 2015-12-25 13:42:18 n_leaf_pages 1 NULL Number of leaf pages in the index
test t GEN_CLUST_INDEX 2015-12-25 13:42:18 size 1 NULL Number of pages in the index
test t vidx 2015-12-25 13:42:18 n_diff_pfx01 2 1 d
test t vidx 2015-12-25 13:42:18 n_diff_pfx02 2 1 d,DB_ROW_ID
test t vidx 2015-12-25 13:42:18 n_leaf_pages 1 NULL Number of leaf pages in the index
test t vidx 2015-12-25 13:42:18 size 1 NULL Number of pages in the index