413 lines
24 KiB
Plaintext
413 lines
24 KiB
Plaintext
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1
|
|
(
|
|
key1 INT NOT NULL,
|
|
key2 INT NOT NULL,
|
|
key3 INT NOT NULL,
|
|
key4 INT NOT NULL,
|
|
key5 INT,
|
|
key6 INT,
|
|
key7 INT NOT NULL,
|
|
key8 INT NOT NULL,
|
|
INDEX i1(key1),
|
|
INDEX i2(key2),
|
|
INDEX i3(key3),
|
|
INDEX i4(key4),
|
|
INDEX i5(key5),
|
|
INDEX i6(key6)
|
|
);
|
|
ANALYZE TABLE t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 analyze status OK
|
|
DROP TABLE IF EXISTS t2;
|
|
CREATE TABLE t2 LIKE t1;
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
ANALYZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 analyze status OK
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key3=1025 OR key5 IS NULL;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i3,i5 i3,i5 4,5 NULL # 100.00 Using union(i3,i5); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key3` = 1025) or (`test`.`t1`.`key5` is null))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
10
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key3=1025 OR key5 IS NULL;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
20
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key1=48 OR key4=2 OR key6=3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i4,i6 i1,i4,i6 4,4,5 NULL # 100.00 Using union(i1,i4,i6); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` = 48) or (`test`.`t1`.`key4` = 2) or (`test`.`t1`.`key6` = 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
20
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key1=48 OR key4=2 OR key6=3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
24
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
24
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
26
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE (key1>30 AND key1<35) OR (key2>32 AND key2<40);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where (((`test`.`t1`.`key1` > 30) and (`test`.`t1`.`key1` < 35)) or ((`test`.`t1`.`key2` > 32) and (`test`.`t1`.`key2` < 40)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
26
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE (key1>30 AND key1<35) OR (key2>32 AND key2<40);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
35
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 IGNORE INDEX(i2) WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL ALL i1 NULL NULL NULL # 55.55 Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` IGNORE INDEX (`i2`) where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
35
|
|
REPLACE INTO t2 SELECT * FROM t1 IGNORE INDEX(i2) WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
37
|
|
INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 USE INDEX(i6,i3) WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i3,i6 i6,i3 5,4 NULL # 1.00 Using union(i6,i3); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` USE INDEX (`i3`) USE INDEX (`i6`) where (((`test`.`t1`.`key6` = 3) and (`test`.`t1`.`key4` = 42)) or ((`test`.`t1`.`key3` = 6) and (`test`.`t1`.`key1` = 4)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
37
|
|
REPLACE INTO t2 SELECT * FROM t1 USE INDEX(i6,i3) WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
39
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 FORCE INDEX(i1,i2) WHERE (key1>1 OR key2>2);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((`test`.`t1`.`key1` > 1) or (`test`.`t1`.`key2` > 2))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
39
|
|
REPLACE INTO t2 SELECT * FROM t1 FORCE INDEX(i1,i2) WHERE (key1>1 OR key2>2);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2097
|
|
INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6) AND key5<>50;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i3,i4,i5,i6 i4,i6,i1,i3 4,5,4,4 NULL # 100.00 Using union(intersect(i4,i6),intersect(i1,i3)); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where (((`test`.`t1`.`key6` = 3) and (`test`.`t1`.`key4` = 42)) or ((`test`.`t1`.`key3` = 6) and (`test`.`t1`.`key1` = 4) and (`test`.`t1`.`key5` <> 50)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2097
|
|
INSERT INTO t2 SELECT * FROM t1 WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6) AND key5<>50;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2101
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using union(i2,i3); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) or (`test`.`t1`.`key3` = 3) or (`test`.`t1`.`key4` <=> NULL))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2101
|
|
INSERT INTO t2 SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null ;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2104
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 IGNORE INDEX(i1) WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL ALL i2 NULL NULL NULL # 55.55 Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` IGNORE INDEX (`i1`) where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2104
|
|
INSERT INTO t2 SELECT * FROM t1 IGNORE INDEX(i1) WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2106
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 USE INDEX(i5,i6) WHERE (key1<2 OR key2<2) AND (key3<3 OR key4<3) AND (key5<5 OR key6<5);;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i5,i6 i5,i6 5,5 NULL # 30.86 Using sort_union(i5,i6); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` USE INDEX (`i6`) USE INDEX (`i5`) where (((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 2)) and ((`test`.`t1`.`key3` < 3) or (`test`.`t1`.`key4` < 3)) and ((`test`.`t1`.`key5` < 5) or (`test`.`t1`.`key6` < 5)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2106
|
|
INSERT INTO t2 SELECT * FROM t1 USE INDEX(i5,i6) WHERE (key1<2 OR key2<2) AND (key3<3 OR key4<3) AND (key5<5 OR key6<5);;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2107
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 FORCE INDEX(i4,i5) WHERE (key4>3 OR key5>5);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i4,i5 i4,i5 4,5 NULL # 100.00 Using sort_union(i4,i5); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` FORCE INDEX (`i5`) FORCE INDEX (`i4`) where ((`test`.`t1`.`key4` > 3) or (`test`.`t1`.`key5` > 5))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2107
|
|
INSERT INTO t2 SELECT * FROM t1 FORCE INDEX(i4,i5) WHERE (key4>3 OR key5>5);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
4165
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1
|
|
(
|
|
key1 INT NOT NULL,
|
|
key2 INT NOT NULL,
|
|
key3 INT NOT NULL,
|
|
key4 INT NOT NULL,
|
|
key5 INT,
|
|
key6 INT,
|
|
key7 INT NOT NULL,
|
|
key8 INT NOT NULL,
|
|
INDEX i1(key1,key2),
|
|
INDEX i2(key2,key1),
|
|
INDEX i3(key3,key4),
|
|
INDEX i4(key4,key3),
|
|
INDEX i5(key5,key6),
|
|
INDEX i6(key6,key5),
|
|
INDEX i7(key7,key8),
|
|
INDEX i8(key8,key7)
|
|
);
|
|
ANALYZE TABLE t1;
|
|
Table Op Msg_type Msg_text
|
|
test.t1 analyze status OK
|
|
DROP TABLE IF EXISTS t2;
|
|
CREATE TABLE t2 LIKE t1;
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
INSERT INTO t2 VALUES (rand()*6, rand()*6, rand()*6, rand()*6,
|
|
rand()*6, rand()*6, rand()*6, rand()*6);
|
|
ANALYZE TABLE t2;
|
|
Table Op Msg_type Msg_text
|
|
test.t2 analyze status OK
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key3=1025 OR key5 IS NULL;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i3,i5 i3,i5 4,5 NULL # 100.00 Using sort_union(i3,i5); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key3` = 1025) or (`test`.`t1`.`key5` is null))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
10
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key3=1025 OR key5 IS NULL;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
20
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key1=48 OR key4=2 OR key6=3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i4,i6 i1,i4,i6 4,4,5 NULL # 100.00 Using sort_union(i1,i4,i6); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` = 48) or (`test`.`t1`.`key4` = 2) or (`test`.`t1`.`key6` = 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
20
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key1=48 OR key4=2 OR key6=3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
24
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
24
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
26
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 WHERE (key1>30 AND key1<35) OR (key2>32 AND key2<40);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where (((`test`.`t1`.`key1` > 30) and (`test`.`t1`.`key1` < 35)) or ((`test`.`t1`.`key2` > 32) and (`test`.`t1`.`key2` < 40)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
26
|
|
REPLACE INTO t2 SELECT * FROM t1 WHERE (key1>30 AND key1<35) OR (key2>32 AND key2<40);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
35
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 IGNORE INDEX(i2) WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL ALL i1 NULL NULL NULL # 55.55 Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` IGNORE INDEX (`i2`) where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
35
|
|
REPLACE INTO t2 SELECT * FROM t1 IGNORE INDEX(i2) WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
37
|
|
INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 USE INDEX(i6,i3) WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i3,i6 i6,i3 5,4 NULL # 1.00 Using sort_union(i6,i3); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` USE INDEX (`i3`) USE INDEX (`i6`) where (((`test`.`t1`.`key6` = 3) and (`test`.`t1`.`key4` = 42)) or ((`test`.`t1`.`key3` = 6) and (`test`.`t1`.`key1` = 4)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
37
|
|
REPLACE INTO t2 SELECT * FROM t1 USE INDEX(i6,i3) WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
39
|
|
EXPLAIN REPLACE INTO t2 SELECT * FROM t1 FORCE INDEX(i1,i2) WHERE (key1>1 OR key2>2);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 REPLACE t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i2 i1,i2 4,4 NULL # 100.00 Using sort_union(i1,i2); Using where
|
|
Warnings:
|
|
Note 1003 replace into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` FORCE INDEX (`i2`) FORCE INDEX (`i1`) where ((`test`.`t1`.`key1` > 1) or (`test`.`t1`.`key2` > 2))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
39
|
|
REPLACE INTO t2 SELECT * FROM t1 FORCE INDEX(i1,i2) WHERE (key1>1 OR key2>2);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2097
|
|
INSERT INTO t1 VALUES (42,42,42,42,3,3,3,3),(4,4,6,6,6,6,4,4);
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6) AND key5<>50;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i1,i3,i4,i5,i6 i4,i1 4,4 NULL # 0.83 Using sort_union(i4,i1); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where (((`test`.`t1`.`key6` = 3) and (`test`.`t1`.`key4` = 42)) or ((`test`.`t1`.`key3` = 6) and (`test`.`t1`.`key1` = 4) and (`test`.`t1`.`key5` <> 50)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2097
|
|
INSERT INTO t2 SELECT * FROM t1 WHERE (key4=42 AND key6=3) OR (key1=4 AND key3=6) AND key5<>50;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2101
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i2,i3,i4 i2,i3 4,4 NULL # 100.00 Using sort_union(i2,i3); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` where ((`test`.`t1`.`key2` = 10) or (`test`.`t1`.`key3` = 3) or (`test`.`t1`.`key4` <=> NULL))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2101
|
|
INSERT INTO t2 SELECT * FROM t1 WHERE key2=10 OR key3=3 OR key4 <=> null ;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2104
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 IGNORE INDEX(i1) WHERE key1<2 OR key2<3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL ALL i2 NULL NULL NULL # 55.55 Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` IGNORE INDEX (`i1`) where ((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 3))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2104
|
|
INSERT INTO t2 SELECT * FROM t1 IGNORE INDEX(i1) WHERE key1<2 OR key2<3;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2106
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 USE INDEX(i5,i6) WHERE (key1<2 OR key2<2) AND (key3<3 OR key4<3) AND (key5<5 OR key6<5);;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i5,i6 i5,i6 5,5 NULL # 30.86 Using sort_union(i5,i6); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` USE INDEX (`i6`) USE INDEX (`i5`) where (((`test`.`t1`.`key1` < 2) or (`test`.`t1`.`key2` < 2)) and ((`test`.`t1`.`key3` < 3) or (`test`.`t1`.`key4` < 3)) and ((`test`.`t1`.`key5` < 5) or (`test`.`t1`.`key6` < 5)))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2106
|
|
INSERT INTO t2 SELECT * FROM t1 USE INDEX(i5,i6) WHERE (key1<2 OR key2<2) AND (key3<3 OR key4<3) AND (key5<5 OR key6<5);;
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2107
|
|
EXPLAIN INSERT INTO t2 SELECT * FROM t1 FORCE INDEX(i4,i5) WHERE (key4>3 OR key5>5);
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 INSERT t2 NULL ALL NULL NULL NULL NULL # NULL NULL
|
|
1 SIMPLE t1 NULL index_merge i4,i5 i4,i5 4,5 NULL # 100.00 Using sort_union(i4,i5); Using where
|
|
Warnings:
|
|
Note 1003 insert into `test`.`t2` /* select#1 */ select `test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2`,`test`.`t1`.`key3` AS `key3`,`test`.`t1`.`key4` AS `key4`,`test`.`t1`.`key5` AS `key5`,`test`.`t1`.`key6` AS `key6`,`test`.`t1`.`key7` AS `key7`,`test`.`t1`.`key8` AS `key8` from `test`.`t1` FORCE INDEX (`i5`) FORCE INDEX (`i4`) where ((`test`.`t1`.`key4` > 3) or (`test`.`t1`.`key5` > 5))
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
2107
|
|
INSERT INTO t2 SELECT * FROM t1 FORCE INDEX(i4,i5) WHERE (key4>3 OR key5>5);
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
4165
|
|
DROP TABLE t1;
|
|
DROP TABLE t2;
|