mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Added procedures to delete records by keys from statistical tables.
Now when a table is dropped the statistics on the table is removed from the statistical tables. If the table is altered in such a way that a column is dropped or the type of the column is changed then statistics on the column is removed from the table column_stat. It also triggers removal of the statistics on the indexes who use this column as its component. Added procedures that changes the names of the tables or columns in the statistical tables for. These procedures are used when tables/columns are renamed. Also partly re-factored the code that introduced the persistent statistical tables. Added test cases into statistics.test to cover the new code.
This commit is contained in:
@ -12,10 +12,10 @@ d date,
|
|||||||
e double,
|
e double,
|
||||||
f bit(3),
|
f bit(3),
|
||||||
INDEX idx1 (b, e),
|
INDEX idx1 (b, e),
|
||||||
INDEX idx2(c, d),
|
INDEX idx2 (c, d),
|
||||||
INDEX idx3 (d),
|
INDEX idx3 (d),
|
||||||
INDEX idx4 (e, b, d)
|
INDEX idx4 (e, b, d)
|
||||||
);
|
) ENGINE= MYISAM;
|
||||||
INSERT INTO t1 VALUES
|
INSERT INTO t1 VALUES
|
||||||
(0, NULL, NULL, NULL, NULL, NULL),
|
(0, NULL, NULL, NULL, NULL, NULL),
|
||||||
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd', '1990-05-15', 0.1, b'100'),
|
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd', '1990-05-15', 0.1, b'100'),
|
||||||
@ -206,6 +206,662 @@ WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
|
|||||||
AS 'ARITY 3';
|
AS 'ARITY 3';
|
||||||
ARITY 1 ARITY 2 ARITY 3
|
ARITY 1 ARITY 2 ARITY 3
|
||||||
6.2000 1.6875 1.1304
|
6.2000 1.6875 1.1304
|
||||||
|
CREATE TABLE t3 (
|
||||||
|
a int NOT NULL PRIMARY KEY,
|
||||||
|
b varchar(32),
|
||||||
|
c char(16),
|
||||||
|
INDEX idx (c)
|
||||||
|
) ENGINE=MYISAM;
|
||||||
|
INSERT INTO t3 VALUES
|
||||||
|
(0, NULL, NULL),
|
||||||
|
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd'),
|
||||||
|
(17, 'vvvvvvvvvvvvv', 'aaaa'),
|
||||||
|
(1, 'vvvvvvvvvvvvv', NULL),
|
||||||
|
(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
|
||||||
|
(23, 'vvvvvvvvvvvvv', 'dddddddd'),
|
||||||
|
(8, 'vvvvvvvvvvvvv', 'aaaa'),
|
||||||
|
(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa'),
|
||||||
|
(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa'),
|
||||||
|
(10, NULL, 'aaaa'),
|
||||||
|
(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
|
||||||
|
(15, 'vvvvvvvvvvvvv', 'ccccccccc'),
|
||||||
|
(30, NULL, 'bbbbbb'),
|
||||||
|
(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb'),
|
||||||
|
(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc'),
|
||||||
|
(9, 'yyy', 'bbbbbb'),
|
||||||
|
(29, 'vvvvvvvvvvvvv', 'dddddddd');
|
||||||
|
ANALYZE TABLE t3;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t3 analyze status OK
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test t1 40
|
||||||
|
test t3 17
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
test t3 a 0 38 0.0000 4.0000 1.0000
|
||||||
|
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
|
||||||
|
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
test t3 PRIMARY 1 1.0000
|
||||||
|
test t3 idx 1 3.7500
|
||||||
|
ALTER TABLE t1 RENAME TO s1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test s1 40
|
||||||
|
test t3 17
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test s1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test s1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test s1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test s1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test s1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
test t3 a 0 38 0.0000 4.0000 1.0000
|
||||||
|
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
|
||||||
|
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test s1 PRIMARY 1 1.0000
|
||||||
|
test s1 idx1 1 6.4000
|
||||||
|
test s1 idx1 2 1.6875
|
||||||
|
test s1 idx2 1 7.0000
|
||||||
|
test s1 idx2 2 2.3846
|
||||||
|
test s1 idx3 1 8.5000
|
||||||
|
test s1 idx4 1 6.2000
|
||||||
|
test s1 idx4 2 1.6875
|
||||||
|
test s1 idx4 3 1.1304
|
||||||
|
test t3 PRIMARY 1 1.0000
|
||||||
|
test t3 idx 1 3.7500
|
||||||
|
RENAME TABLE s1 TO t1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test t1 40
|
||||||
|
test t3 17
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
test t3 a 0 38 0.0000 4.0000 1.0000
|
||||||
|
test t3 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.1765 18.0714 2.8000
|
||||||
|
test t3 c aaaa dddddddd 0.1176 6.4000 3.7500
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
test t3 PRIMARY 1 1.0000
|
||||||
|
test t3 idx 1 3.7500
|
||||||
|
DROP TABLE t3;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test t1 40
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
CREATE TEMPORARY TABLE t0 (
|
||||||
|
a int NOT NULL PRIMARY KEY,
|
||||||
|
b varchar(32)
|
||||||
|
);
|
||||||
|
INSERT INTO t0 SELECT a,b FROM t1;
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(32),
|
||||||
|
CHANGE COLUMN e y double;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`x` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`y` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`x`,`y`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`y`,`x`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 y 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32),
|
||||||
|
CHANGE COLUMN y e double;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
ALTER TABLE t1 RENAME TO s1, CHANGE COLUMN b x varchar(32);
|
||||||
|
SHOW CREATE TABLE s1;
|
||||||
|
Table Create Table
|
||||||
|
s1 CREATE TABLE `s1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`x` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`x`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`x`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test s1 40
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test s1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test s1 x vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test s1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test s1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test s1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test s1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test s1 PRIMARY 1 1.0000
|
||||||
|
test s1 idx1 1 6.4000
|
||||||
|
test s1 idx1 2 1.6875
|
||||||
|
test s1 idx2 1 7.0000
|
||||||
|
test s1 idx2 2 2.3846
|
||||||
|
test s1 idx3 1 8.5000
|
||||||
|
test s1 idx4 1 6.2000
|
||||||
|
test s1 idx4 2 1.6875
|
||||||
|
test s1 idx4 3 1.1304
|
||||||
|
ALTER TABLE s1 RENAME TO t1, CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
test t1 40
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`x` varchar(30) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`x`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`x`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx4);
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/save_column_stat'
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
|
||||||
|
FROM mysql.column_stat WHERE column_name='b';
|
||||||
|
SELECT * INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/save_index_stat'
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
|
||||||
|
FROM mysql.index_stat WHERE index_name IN ('idx1', 'idx4');
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`x` varchar(30) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`x`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`x`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_column_stat'
|
||||||
|
INTO TABLE mysql.column_stat
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
|
||||||
|
LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/save_index_stat'
|
||||||
|
INTO TABLE mysql.index_stat
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
ALTER TABLE t1 DROP COLUMN b;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
DROP INDEX idx2 ON t1;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx1` (`e`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx4` (`e`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
DROP INDEX idx1 ON t1;
|
||||||
|
DROP INDEX idx4 ON t1;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx3` (`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
ALTER TABLE t1 ADD COLUMN b varchar(32);
|
||||||
|
CREATE INDEX idx1 ON t1(b, e);
|
||||||
|
CREATE INDEX idx2 ON t1(c, d);
|
||||||
|
CREATE INDEX idx4 ON t1(e, b, d);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b NULL NULL 1.0000 NULL NULL
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx1 2 NULL
|
||||||
|
test t1 idx1 1 NULL
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 NULL
|
||||||
|
test t1 idx4 3 NULL
|
||||||
|
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
|
ALTER TABLE t1 DROP COLUMN b,
|
||||||
|
DROP INDEX idx1, DROP INDEX idx2, DROP INDEX idx4;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx3` (`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
ALTER TABLE t1 ADD COLUMN b varchar(32);
|
||||||
|
ALTER TABLE t1
|
||||||
|
ADD INDEX idx1 (b, e), ADD INDEX idx2 (c, d), ADD INDEX idx4 (e, b, d);
|
||||||
|
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`a` int(11) NOT NULL,
|
||||||
|
`c` char(16) DEFAULT NULL,
|
||||||
|
`d` date DEFAULT NULL,
|
||||||
|
`e` double DEFAULT NULL,
|
||||||
|
`f` bit(3) DEFAULT NULL,
|
||||||
|
`b` varchar(32) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`a`),
|
||||||
|
KEY `idx3` (`d`),
|
||||||
|
KEY `idx1` (`b`,`e`),
|
||||||
|
KEY `idx2` (`c`,`d`),
|
||||||
|
KEY `idx4` (`e`,`b`,`d`)
|
||||||
|
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.t1 analyze status OK
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx4 1 6.2000
|
||||||
|
test t1 idx4 2 1.6875
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
|
test t1 idx2 2 2.3846
|
||||||
|
test t1 idx2 1 7.0000
|
||||||
|
test t1 idx1 2 1.6875
|
||||||
|
test t1 idx1 1 6.4000
|
||||||
|
test t1 idx4 3 1.1304
|
||||||
DELETE FROM mysql.table_stat;
|
DELETE FROM mysql.table_stat;
|
||||||
DELETE FROM mysql.column_stat;
|
DELETE FROM mysql.column_stat;
|
||||||
DELETE FROM mysql.index_stat;
|
DELETE FROM mysql.index_stat;
|
||||||
@ -227,9 +883,9 @@ db_name table_name cardinality
|
|||||||
test t1 40
|
test t1 40
|
||||||
SELECT * FROM mysql.column_stat;
|
SELECT * FROM mysql.column_stat;
|
||||||
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
|
||||||
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
SELECT * FROM mysql.index_stat;
|
SELECT * FROM mysql.index_stat;
|
||||||
db_name table_name index_name prefix_arity avg_frequency
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
test t1 idx2 1 7.0000
|
test t1 idx2 1 7.0000
|
||||||
@ -249,19 +905,19 @@ test t1 40
|
|||||||
SELECT * FROM mysql.column_stat;
|
SELECT * FROM mysql.column_stat;
|
||||||
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
test t1 a 0 49 0.0000 4.0000 1.0000
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
|
||||||
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
test t1 f 1 5 0.2000 1.0000 6.4000
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 17.1250 6.4000
|
||||||
SELECT * FROM mysql.index_stat;
|
SELECT * FROM mysql.index_stat;
|
||||||
db_name table_name index_name prefix_arity avg_frequency
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
test t1 PRIMARY 1 1.0000
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
test t1 idx1 1 6.4000
|
test t1 idx1 1 6.4000
|
||||||
test t1 idx1 2 1.6875
|
test t1 idx1 2 1.6875
|
||||||
test t1 idx2 1 7.0000
|
test t1 idx2 1 7.0000
|
||||||
test t1 idx2 2 2.3846
|
test t1 idx2 2 2.3846
|
||||||
test t1 idx3 1 8.5000
|
|
||||||
test t1 idx4 1 6.2000
|
test t1 idx4 1 6.2000
|
||||||
test t1 idx4 2 1.6875
|
test t1 idx4 2 1.6875
|
||||||
test t1 idx4 3 1.1304
|
test t1 idx4 3 1.1304
|
||||||
@ -325,17 +981,17 @@ test.t1 analyze status OK
|
|||||||
SELECT * FROM mysql.column_stat;
|
SELECT * FROM mysql.column_stat;
|
||||||
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
test t1 a 0 49 0.0000 4.0000 1.0000
|
test t1 a 0 49 0.0000 4.0000 1.0000
|
||||||
test t1 b NULL NULL 0.2000 17.1250 NULL
|
|
||||||
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
test t1 c aaaa dddddddd 0.1250 6.6571 7.0000
|
||||||
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
test t1 d 1989-03-12 1999-07-23 0.1500 3.0000 8.5000
|
||||||
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
test t1 e 0.01 0.112 0.2250 8.0000 6.2000
|
||||||
test t1 f 1 5 0.2000 1.0000 6.4000
|
test t1 f 1 5 0.2000 1.0000 6.4000
|
||||||
|
test t1 b NULL NULL 0.2000 17.1250 NULL
|
||||||
SELECT * FROM mysql.index_stat;
|
SELECT * FROM mysql.index_stat;
|
||||||
db_name table_name index_name prefix_arity avg_frequency
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
test t1 PRIMARY 1 1.0000
|
test t1 PRIMARY 1 1.0000
|
||||||
|
test t1 idx3 1 8.5000
|
||||||
test t1 idx2 1 7.0000
|
test t1 idx2 1 7.0000
|
||||||
test t1 idx2 2 2.3846
|
test t1 idx2 2 2.3846
|
||||||
test t1 idx3 1 8.5000
|
|
||||||
test t1 idx1 1 NULL
|
test t1 idx1 1 NULL
|
||||||
test t1 idx1 2 NULL
|
test t1 idx1 2 NULL
|
||||||
test t1 idx4 1 6.2000
|
test t1 idx4 1 6.2000
|
||||||
@ -503,7 +1159,42 @@ WORLD_INNODB COUNTRYLANGUAGE PRIMARY 2 1.0000
|
|||||||
WORLD_INNODB COUNTRYLANGUAGE Percentage 1 2.7640
|
WORLD_INNODB COUNTRYLANGUAGE Percentage 1 2.7640
|
||||||
use test;
|
use test;
|
||||||
DROP DATABASE world;
|
DROP DATABASE world;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
world_innodb Country 239
|
||||||
|
world_innodb City 4079
|
||||||
|
world_innodb CountryLanguage 984
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
world_innodb Country Code ABW ZWE 0.0000 3.0000 1.0000
|
||||||
|
world_innodb Country Name Afghanistan Zimbabwe 0.0000 10.1088 1.0000
|
||||||
|
world_innodb Country SurfaceArea 0.40 17075400.00 0.0000 4.0000 1.0042
|
||||||
|
world_innodb Country Population 0 1277558000 0.0000 4.0000 1.0575
|
||||||
|
world_innodb Country Capital 1 4074 0.0293 4.0000 1.0000
|
||||||
|
world_innodb City ID 1 4079 0.0000 4.0000 1.0000
|
||||||
|
world_innodb City Name A Coruña (La Coruña) Ürgenc 0.0000 8.6416 1.0195
|
||||||
|
world_innodb City Country ABW ZWE 0.0000 3.0000 17.5819
|
||||||
|
world_innodb City Population 42 10500000 0.0000 4.0000 1.0467
|
||||||
|
world_innodb CountryLanguage Country ABW ZWE 0.0000 3.0000 4.2232
|
||||||
|
world_innodb CountryLanguage Language Abhyasi [South]Mande 0.0000 7.1778 2.1532
|
||||||
|
world_innodb CountryLanguage Percentage 0.0 99.9 0.0000 4.0000 2.7640
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
|
world_innodb Country PRIMARY 1 1.0000
|
||||||
|
world_innodb Country Name 1 1.0000
|
||||||
|
world_innodb City PRIMARY 1 1.0000
|
||||||
|
world_innodb City Population 1 1.0467
|
||||||
|
world_innodb City Country 1 17.5819
|
||||||
|
world_innodb CountryLanguage PRIMARY 1 4.2232
|
||||||
|
world_innodb CountryLanguage PRIMARY 2 1.0000
|
||||||
|
world_innodb CountryLanguage Percentage 1 2.7640
|
||||||
DROP DATABASE world_innodb;
|
DROP DATABASE world_innodb;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
db_name table_name cardinality
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
db_name table_name index_name prefix_arity avg_frequency
|
||||||
DELETE FROM mysql.table_stat;
|
DELETE FROM mysql.table_stat;
|
||||||
DELETE FROM mysql.column_stat;
|
DELETE FROM mysql.column_stat;
|
||||||
DELETE FROM mysql.index_stat;
|
DELETE FROM mysql.index_stat;
|
||||||
|
@ -107,7 +107,7 @@ Handler_mrr_key_refills 0
|
|||||||
Handler_mrr_rowid_refills 0
|
Handler_mrr_rowid_refills 0
|
||||||
Handler_prepare 18
|
Handler_prepare 18
|
||||||
Handler_read_first 0
|
Handler_read_first 0
|
||||||
Handler_read_key 3
|
Handler_read_key 9
|
||||||
Handler_read_last 0
|
Handler_read_last 0
|
||||||
Handler_read_next 0
|
Handler_read_next 0
|
||||||
Handler_read_prev 0
|
Handler_read_prev 0
|
||||||
@ -123,7 +123,7 @@ Handler_update 5
|
|||||||
Handler_write 7
|
Handler_write 7
|
||||||
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
|
select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key";
|
||||||
handler_read_key
|
handler_read_key
|
||||||
3
|
9
|
||||||
set @@global.userstat=0;
|
set @@global.userstat=0;
|
||||||
select * from information_schema.index_statistics;
|
select * from information_schema.index_statistics;
|
||||||
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ
|
||||||
|
@ -17,6 +17,7 @@ substring(object_name, locate("no_index_tab", object_name)) as short_name
|
|||||||
from performance_schema.events_waits_history_long
|
from performance_schema.events_waits_history_long
|
||||||
where operation not like "tell"
|
where operation not like "tell"
|
||||||
and event_name like "wait/io/file/myisam/%"
|
and event_name like "wait/io/file/myisam/%"
|
||||||
|
having short_name <> ""
|
||||||
order by thread_id, event_id;
|
order by thread_id, event_id;
|
||||||
event_name short_source operation number_of_bytes short_name
|
event_name short_source operation number_of_bytes short_name
|
||||||
wait/io/file/myisam/kfile mi_create.c: create NULL no_index_tab.MYI
|
wait/io/file/myisam/kfile mi_create.c: create NULL no_index_tab.MYI
|
||||||
|
@ -46,6 +46,7 @@ select event_name,
|
|||||||
from performance_schema.events_waits_history_long
|
from performance_schema.events_waits_history_long
|
||||||
where operation not like "tell"
|
where operation not like "tell"
|
||||||
and event_name like "wait/io/file/myisam/%"
|
and event_name like "wait/io/file/myisam/%"
|
||||||
|
having short_name <> ""
|
||||||
order by thread_id, event_id;
|
order by thread_id, event_id;
|
||||||
|
|
||||||
# In case of failures, this will tell if file io are lost.
|
# In case of failures, this will tell if file io are lost.
|
||||||
|
@ -20,10 +20,10 @@ CREATE TABLE t1 (
|
|||||||
e double,
|
e double,
|
||||||
f bit(3),
|
f bit(3),
|
||||||
INDEX idx1 (b, e),
|
INDEX idx1 (b, e),
|
||||||
INDEX idx2(c, d),
|
INDEX idx2 (c, d),
|
||||||
INDEX idx3 (d),
|
INDEX idx3 (d),
|
||||||
INDEX idx4 (e, b, d)
|
INDEX idx4 (e, b, d)
|
||||||
);
|
) ENGINE= MYISAM;
|
||||||
|
|
||||||
INSERT INTO t1 VALUES
|
INSERT INTO t1 VALUES
|
||||||
(0, NULL, NULL, NULL, NULL, NULL),
|
(0, NULL, NULL, NULL, NULL, NULL),
|
||||||
@ -165,6 +165,180 @@ SELECT
|
|||||||
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
|
WHERE t1.e IS NOT NULL AND t1.b IS NOT NULL AND t1.d IS NOT NULL)
|
||||||
AS 'ARITY 3';
|
AS 'ARITY 3';
|
||||||
|
|
||||||
|
CREATE TABLE t3 (
|
||||||
|
a int NOT NULL PRIMARY KEY,
|
||||||
|
b varchar(32),
|
||||||
|
c char(16),
|
||||||
|
INDEX idx (c)
|
||||||
|
) ENGINE=MYISAM;
|
||||||
|
|
||||||
|
INSERT INTO t3 VALUES
|
||||||
|
(0, NULL, NULL),
|
||||||
|
(7, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'dddddddd'),
|
||||||
|
(17, 'vvvvvvvvvvvvv', 'aaaa'),
|
||||||
|
(1, 'vvvvvvvvvvvvv', NULL),
|
||||||
|
(12, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
|
||||||
|
(23, 'vvvvvvvvvvvvv', 'dddddddd'),
|
||||||
|
(8, 'vvvvvvvvvvvvv', 'aaaa'),
|
||||||
|
(22, 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'aaaa'),
|
||||||
|
(31, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'aaaa'),
|
||||||
|
(10, NULL, 'aaaa'),
|
||||||
|
(5, 'wwwwwwwwwwwwwwwwwwwwwwwwwwww', 'dddddddd'),
|
||||||
|
(15, 'vvvvvvvvvvvvv', 'ccccccccc'),
|
||||||
|
(30, NULL, 'bbbbbb'),
|
||||||
|
(38, 'zzzzzzzzzzzzzzzzzz', 'bbbbbb'),
|
||||||
|
(18, 'zzzzzzzzzzzzzzzzzz', 'ccccccccc'),
|
||||||
|
(9, 'yyy', 'bbbbbb'),
|
||||||
|
(29, 'vvvvvvvvvvvvv', 'dddddddd');
|
||||||
|
|
||||||
|
ANALYZE TABLE t3;
|
||||||
|
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 RENAME TO s1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
RENAME TABLE s1 TO t1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
DROP TABLE t3;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TEMPORARY TABLE t0 (
|
||||||
|
a int NOT NULL PRIMARY KEY,
|
||||||
|
b varchar(32)
|
||||||
|
);
|
||||||
|
INSERT INTO t0 SELECT a,b FROM t1;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(32),
|
||||||
|
CHANGE COLUMN e y double;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32),
|
||||||
|
CHANGE COLUMN y e double;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 RENAME TO s1, CHANGE COLUMN b x varchar(32);
|
||||||
|
SHOW CREATE TABLE s1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE s1 RENAME TO t1, CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx4);
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||||
|
eval
|
||||||
|
SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/save_column_stat'
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
|
||||||
|
FROM mysql.column_stat WHERE column_name='b';
|
||||||
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||||
|
eval
|
||||||
|
SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/save_index_stat'
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
|
||||||
|
FROM mysql.index_stat WHERE index_name IN ('idx1', 'idx4');
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN b x varchar(30);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 CHANGE COLUMN x b varchar(32);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||||
|
eval
|
||||||
|
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_column_stat'
|
||||||
|
INTO TABLE mysql.column_stat
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
|
||||||
|
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
|
||||||
|
eval
|
||||||
|
LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/save_index_stat'
|
||||||
|
INTO TABLE mysql.index_stat
|
||||||
|
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
remove_file $MYSQLTEST_VARDIR/tmp/save_column_stat;
|
||||||
|
remove_file $MYSQLTEST_VARDIR/tmp/save_index_stat;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE t1 DROP COLUMN b;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
DROP INDEX idx2 ON t1;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
DROP INDEX idx1 ON t1;
|
||||||
|
DROP INDEX idx4 ON t1;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD COLUMN b varchar(32);
|
||||||
|
CREATE INDEX idx1 ON t1(b, e);
|
||||||
|
CREATE INDEX idx2 ON t1(c, d);
|
||||||
|
CREATE INDEX idx4 ON t1(e, b, d);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 DROP COLUMN b,
|
||||||
|
DROP INDEX idx1, DROP INDEX idx2, DROP INDEX idx4;
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
|
ALTER TABLE t1 ADD COLUMN b varchar(32);
|
||||||
|
ALTER TABLE t1
|
||||||
|
ADD INDEX idx1 (b, e), ADD INDEX idx2 (c, d), ADD INDEX idx4 (e, b, d);
|
||||||
|
UPDATE t1 SET b=(SELECT b FROM t0 WHERE t0.a= t1.a);
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
ANALYZE TABLE t1 PERSISTENT FOR COLUMNS(b) INDEXES(idx1, idx2, idx4);
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
DELETE FROM mysql.table_stat;
|
DELETE FROM mysql.table_stat;
|
||||||
DELETE FROM mysql.column_stat;
|
DELETE FROM mysql.column_stat;
|
||||||
DELETE FROM mysql.index_stat;
|
DELETE FROM mysql.index_stat;
|
||||||
@ -297,7 +471,14 @@ SELECT UPPER(db_name), UPPER(table_name),
|
|||||||
use test;
|
use test;
|
||||||
|
|
||||||
DROP DATABASE world;
|
DROP DATABASE world;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
DROP DATABASE world_innodb;
|
DROP DATABASE world_innodb;
|
||||||
|
SELECT * FROM mysql.table_stat;
|
||||||
|
SELECT * FROM mysql.column_stat;
|
||||||
|
SELECT * FROM mysql.index_stat;
|
||||||
|
|
||||||
DELETE FROM mysql.table_stat;
|
DELETE FROM mysql.table_stat;
|
||||||
DELETE FROM mysql.column_stat;
|
DELETE FROM mysql.column_stat;
|
||||||
|
@ -9649,7 +9649,8 @@ unlock_tables_n_open_system_tables_for_write(THD *thd,
|
|||||||
|
|
||||||
DBUG_ENTER("unlock_tables_n_open_system_tables_for_write");
|
DBUG_ENTER("unlock_tables_n_open_system_tables_for_write");
|
||||||
|
|
||||||
mysql_unlock_tables(thd, thd->lock);
|
if (thd->lock)
|
||||||
|
mysql_unlock_tables(thd, thd->lock);
|
||||||
thd->lock= 0;
|
thd->lock= 0;
|
||||||
|
|
||||||
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
|
lex->reset_n_backup_query_tables_list(&query_tables_list_backup);
|
||||||
|
@ -315,6 +315,13 @@ int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);
|
|||||||
int read_statistics_for_table(THD *thd, TABLE *table);
|
int read_statistics_for_table(THD *thd, TABLE *table);
|
||||||
int collect_statistics_for_table(THD *thd, TABLE *table);
|
int collect_statistics_for_table(THD *thd, TABLE *table);
|
||||||
int update_statistics_for_table(THD *thd, TABLE *table);
|
int update_statistics_for_table(THD *thd, TABLE *table);
|
||||||
|
int delete_statistics_for_table(THD *thd, LEX_STRING *db, LEX_STRING *tab);
|
||||||
|
int delete_statistics_for_column(THD *thd, TABLE *tab, Field *col);
|
||||||
|
int delete_statistics_for_index(THD *thd, TABLE *tab, KEY *key_info);
|
||||||
|
int rename_table_in_stat_tables(THD *thd, LEX_STRING *db, LEX_STRING *tab,
|
||||||
|
LEX_STRING *new_db, LEX_STRING *new_tab);
|
||||||
|
int rename_column_in_stat_tables(THD *thd, TABLE *tab, Field *col,
|
||||||
|
const char *new_name);
|
||||||
void set_statistics_for_table(THD *thd, TABLE *table);
|
void set_statistics_for_table(THD *thd, TABLE *table);
|
||||||
|
|
||||||
extern "C" int simple_raw_key_cmp(void* arg, const void* key1,
|
extern "C" int simple_raw_key_cmp(void* arg, const void* key1,
|
||||||
|
@ -825,6 +825,17 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
|||||||
lock_db_routines(thd, db))
|
lock_db_routines(thd, db))
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
|
if (!in_bootstrap)
|
||||||
|
{
|
||||||
|
for (table= tables; table; table= table->next_local)
|
||||||
|
{
|
||||||
|
LEX_STRING db_name= { table->db, table->db_length };
|
||||||
|
LEX_STRING table_name= { table->table_name, table->table_name_length };
|
||||||
|
if (table->open_type == OT_BASE_ONLY || !find_temporary_table(thd, table))
|
||||||
|
(void) delete_statistics_for_table(thd, &db_name, &table_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* mysql_ha_rm_tables() requires a non-null TABLE_LIST. */
|
/* mysql_ha_rm_tables() requires a non-null TABLE_LIST. */
|
||||||
if (tables)
|
if (tables)
|
||||||
mysql_ha_rm_tables(thd, tables);
|
mysql_ha_rm_tables(thd, tables);
|
||||||
|
@ -279,6 +279,12 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
|
|||||||
ren_table->db, old_alias,
|
ren_table->db, old_alias,
|
||||||
new_db, new_alias, 0)))
|
new_db, new_alias, 0)))
|
||||||
{
|
{
|
||||||
|
LEX_STRING db_name= { ren_table->db, ren_table->db_length };
|
||||||
|
LEX_STRING table_name= { ren_table->table_name,
|
||||||
|
ren_table->table_name_length };
|
||||||
|
LEX_STRING new_table= { (char *) new_alias, strlen(new_alias) };
|
||||||
|
(void) rename_table_in_stat_tables(thd, &db_name, &table_name,
|
||||||
|
&db_name, &new_table);
|
||||||
if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db,
|
if ((rc= Table_triggers_list::change_table_name(thd, ren_table->db,
|
||||||
old_alias,
|
old_alias,
|
||||||
ren_table->table_name,
|
ren_table->table_name,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1878,6 +1878,17 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!in_bootstrap)
|
||||||
|
{
|
||||||
|
for (table= tables; table; table= table->next_local)
|
||||||
|
{
|
||||||
|
LEX_STRING db_name= { table->db, table->db_length };
|
||||||
|
LEX_STRING table_name= { table->table_name, table->table_name_length };
|
||||||
|
if (table->open_type == OT_BASE_ONLY || !find_temporary_table(thd, table))
|
||||||
|
(void) delete_statistics_for_table(thd, &db_name, &table_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mysql_ha_rm_tables(thd, tables);
|
mysql_ha_rm_tables(thd, tables);
|
||||||
|
|
||||||
if (!drop_temporary)
|
if (!drop_temporary)
|
||||||
@ -1888,6 +1899,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
|||||||
MYSQL_OPEN_SKIP_TEMPORARY))
|
MYSQL_OPEN_SKIP_TEMPORARY))
|
||||||
DBUG_RETURN(true);
|
DBUG_RETURN(true);
|
||||||
for (table= tables; table; table= table->next_local)
|
for (table= tables; table; table= table->next_local)
|
||||||
|
|
||||||
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name,
|
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db, table->table_name,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
@ -5084,6 +5096,21 @@ mysql_compare_tables(TABLE *table,
|
|||||||
thd->calloc(sizeof(void*) * table->s->keys)) == NULL)
|
thd->calloc(sizeof(void*) * table->s->keys)) == NULL)
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
|
|
||||||
|
tmp_new_field_it.init(tmp_alter_info.create_list);
|
||||||
|
for (i= 0, f_ptr= table->field, tmp_new_field= tmp_new_field_it++;
|
||||||
|
(field= *f_ptr);
|
||||||
|
i++, f_ptr++, tmp_new_field= tmp_new_field_it++)
|
||||||
|
{
|
||||||
|
if (field->is_equal(tmp_new_field) == IS_EQUAL_NO &&
|
||||||
|
table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
(void) delete_statistics_for_column(thd, table, field);
|
||||||
|
else if (my_strcasecmp(system_charset_info,
|
||||||
|
field->field_name,
|
||||||
|
tmp_new_field->field_name))
|
||||||
|
(void) rename_column_in_stat_tables(thd, table, field,
|
||||||
|
tmp_new_field->field_name);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Use transformed info to evaluate possibility of in-place ALTER TABLE
|
Use transformed info to evaluate possibility of in-place ALTER TABLE
|
||||||
but use the preserved field to persist modifications.
|
but use the preserved field to persist modifications.
|
||||||
@ -5144,7 +5171,12 @@ mysql_compare_tables(TABLE *table,
|
|||||||
if (my_strcasecmp(system_charset_info,
|
if (my_strcasecmp(system_charset_info,
|
||||||
field->field_name,
|
field->field_name,
|
||||||
tmp_new_field->field_name))
|
tmp_new_field->field_name))
|
||||||
field->flags|= FIELD_IS_RENAMED;
|
{
|
||||||
|
field->flags|= FIELD_IS_RENAMED;
|
||||||
|
if (table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
rename_column_in_stat_tables(thd, table, field,
|
||||||
|
tmp_new_field->field_name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Evaluate changes bitmap and send to check_if_incompatible_data() */
|
/* Evaluate changes bitmap and send to check_if_incompatible_data() */
|
||||||
if (!(tmp= field->is_equal(tmp_new_field)))
|
if (!(tmp= field->is_equal(tmp_new_field)))
|
||||||
@ -5247,6 +5279,8 @@ mysql_compare_tables(TABLE *table,
|
|||||||
field= table->field[key_part->fieldnr];
|
field= table->field[key_part->fieldnr];
|
||||||
field->flags|= FIELD_IN_ADD_INDEX;
|
field->flags|= FIELD_IN_ADD_INDEX;
|
||||||
}
|
}
|
||||||
|
if (table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
(void) delete_statistics_for_index(thd, table, table_key);
|
||||||
DBUG_PRINT("info", ("index changed: '%s'", table_key->name));
|
DBUG_PRINT("info", ("index changed: '%s'", table_key->name));
|
||||||
}
|
}
|
||||||
/*end of for (; table_key < table_key_end;) */
|
/*end of for (; table_key < table_key_end;) */
|
||||||
@ -5504,6 +5538,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||||||
}
|
}
|
||||||
if (drop)
|
if (drop)
|
||||||
{
|
{
|
||||||
|
if (table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
(void) delete_statistics_for_column(thd, table, field);
|
||||||
drop_it.remove();
|
drop_it.remove();
|
||||||
/*
|
/*
|
||||||
ALTER TABLE DROP COLUMN always changes table data even in cases
|
ALTER TABLE DROP COLUMN always changes table data even in cases
|
||||||
@ -5656,12 +5692,15 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||||||
}
|
}
|
||||||
if (drop)
|
if (drop)
|
||||||
{
|
{
|
||||||
|
if (table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
(void) delete_statistics_for_index(thd, table, key_info);
|
||||||
drop_it.remove();
|
drop_it.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
KEY_PART_INFO *key_part= key_info->key_part;
|
KEY_PART_INFO *key_part= key_info->key_part;
|
||||||
key_parts.empty();
|
key_parts.empty();
|
||||||
|
bool delete_index_stat= FALSE;
|
||||||
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
|
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
|
||||||
{
|
{
|
||||||
if (!key_part->field)
|
if (!key_part->field)
|
||||||
@ -5684,7 +5723,10 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!cfield)
|
if (!cfield)
|
||||||
|
{
|
||||||
|
delete_index_stat= TRUE;
|
||||||
continue; // Field is removed
|
continue; // Field is removed
|
||||||
|
}
|
||||||
key_part_length= key_part->length;
|
key_part_length= key_part->length;
|
||||||
if (cfield->field) // Not new field
|
if (cfield->field) // Not new field
|
||||||
{
|
{
|
||||||
@ -5726,6 +5768,8 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
|
|||||||
strlen(cfield->field_name),
|
strlen(cfield->field_name),
|
||||||
key_part_length));
|
key_part_length));
|
||||||
}
|
}
|
||||||
|
if (delete_index_stat && table->s->tmp_table == NO_TMP_TABLE)
|
||||||
|
(void) delete_statistics_for_index(thd, table, key_info);
|
||||||
if (key_parts.elements)
|
if (key_parts.elements)
|
||||||
{
|
{
|
||||||
KEY_CREATE_INFO key_create_info;
|
KEY_CREATE_INFO key_create_info;
|
||||||
@ -5905,6 +5949,9 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
enum ha_extra_function extra_func= thd->locked_tables_mode
|
enum ha_extra_function extra_func= thd->locked_tables_mode
|
||||||
? HA_EXTRA_NOT_USED
|
? HA_EXTRA_NOT_USED
|
||||||
: HA_EXTRA_FORCE_REOPEN;
|
: HA_EXTRA_FORCE_REOPEN;
|
||||||
|
LEX_STRING old_db_name= { table_list->db, table_list->db_length };
|
||||||
|
LEX_STRING old_table_name= { table_list->table_name,
|
||||||
|
table_list->table_name_length };
|
||||||
DBUG_ENTER("mysql_alter_table");
|
DBUG_ENTER("mysql_alter_table");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -6209,6 +6256,12 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
*fn_ext(new_name)=0;
|
*fn_ext(new_name)=0;
|
||||||
|
|
||||||
|
LEX_STRING new_db_name= { new_db, strlen(new_db) };
|
||||||
|
LEX_STRING new_table_name= { new_alias, strlen(new_alias) };
|
||||||
|
(void) rename_table_in_stat_tables(thd, &old_db_name, &old_table_name,
|
||||||
|
&new_db_name, &new_table_name);
|
||||||
|
|
||||||
if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias, 0))
|
if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias, 0))
|
||||||
error= -1;
|
error= -1;
|
||||||
else if (Table_triggers_list::change_table_name(thd, db,
|
else if (Table_triggers_list::change_table_name(thd, db,
|
||||||
@ -6920,6 +6973,15 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||||||
table is renamed and the SE is also changed, then an intermediate table
|
table is renamed and the SE is also changed, then an intermediate table
|
||||||
is created and the additional call will not take place.
|
is created and the additional call will not take place.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (new_name != table_name || new_db != db)
|
||||||
|
{
|
||||||
|
LEX_STRING new_db_name= { new_db, strlen(new_db) };
|
||||||
|
LEX_STRING new_table_name= { new_name, strlen(new_name) };
|
||||||
|
(void) rename_table_in_stat_tables(thd, &old_db_name, &old_table_name,
|
||||||
|
&new_db_name, &new_table_name);
|
||||||
|
}
|
||||||
|
|
||||||
if (need_copy_table == ALTER_TABLE_METADATA_ONLY)
|
if (need_copy_table == ALTER_TABLE_METADATA_ONLY)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(new_db_type == old_db_type);
|
DBUG_ASSERT(new_db_type == old_db_type);
|
||||||
|
Reference in New Issue
Block a user