103 lines
2.8 KiB
Plaintext
103 lines
2.8 KiB
Plaintext
SET SESSION DEFAULT_STORAGE_ENGINE = XENGINE;
|
|
drop table if exists t1, t2, t3,t4;
|
|
create table t1 (
|
|
pk1 int not NULL,
|
|
key1 int(11),
|
|
key2 int(11),
|
|
PRIMARY KEY (pk1),
|
|
KEY key1 (key1),
|
|
KEY key2 (key2)
|
|
);
|
|
Warnings:
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
insert into t1 values (-5, 1, 1),
|
|
(-100, 1, 1),
|
|
(3, 1, 1),
|
|
(0, 1, 1),
|
|
(10, 1, 1);
|
|
explain select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
|
|
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
|
|
1 SIMPLE t1 NULL index_merge key1,key2 key1,key2 5,5 NULL # 100.00 Using sort_union(key1,key2); Using where
|
|
Warnings:
|
|
Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`key1` AS `key1`,`test`.`t1`.`key2` AS `key2` from `test`.`t1` FORCE INDEX (`key2`) FORCE INDEX (`key1`) where ((`test`.`t1`.`key1` < 3) or (`test`.`t1`.`key2` < 3))
|
|
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
|
|
pk1 key1 key2
|
|
-100 1 1
|
|
-5 1 1
|
|
0 1 1
|
|
3 1 1
|
|
10 1 1
|
|
drop table t1;
|
|
create table t1 (
|
|
pk1 int unsigned not NULL,
|
|
key1 int(11),
|
|
key2 int(11),
|
|
PRIMARY KEY (pk1),
|
|
KEY key1 (key1),
|
|
KEY key2 (key2)
|
|
);
|
|
Warnings:
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
insert into t1 values (0, 1, 1),
|
|
(0xFFFFFFFF, 1, 1),
|
|
(0xFFFFFFFE, 1, 1),
|
|
(1, 1, 1),
|
|
(2, 1, 1);
|
|
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
|
|
pk1 key1 key2
|
|
0 1 1
|
|
1 1 1
|
|
2 1 1
|
|
4294967294 1 1
|
|
4294967295 1 1
|
|
drop table t1;
|
|
create table t1 (
|
|
pk1 char(4) not NULL,
|
|
key1 int(11),
|
|
key2 int(11),
|
|
PRIMARY KEY (pk1),
|
|
KEY key1 (key1),
|
|
KEY key2 (key2)
|
|
) collate utf8mb4_general_ci;
|
|
Warnings:
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
insert into t1 values ('a1', 1, 1),
|
|
('b2', 1, 1),
|
|
('A3', 1, 1),
|
|
('B4', 1, 1);
|
|
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
|
|
pk1 key1 key2
|
|
a1 1 1
|
|
A3 1 1
|
|
b2 1 1
|
|
B4 1 1
|
|
drop table t1;
|
|
create table t1 (
|
|
pk1 varchar(8) NOT NULL default '',
|
|
pk2 varchar(4) NOT NULL default '',
|
|
key1 int(11),
|
|
key2 int(11),
|
|
primary key(pk1, pk2),
|
|
KEY key1 (key1),
|
|
KEY key2 (key2)
|
|
);
|
|
Warnings:
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
Warning 1681 Integer display width is deprecated and will be removed in a future release.
|
|
insert into t1 values ('','empt',2,2),
|
|
('a','a--a',2,2),
|
|
('bb','b--b',2,2),
|
|
('ccc','c--c',2,2),
|
|
('dddd','d--d',2,2);
|
|
select * from t1 force index(key1, key2) where key1 < 3 or key2 < 3;
|
|
pk1 pk2 key1 key2
|
|
empt 2 2
|
|
a a--a 2 2
|
|
bb b--b 2 2
|
|
ccc c--c 2 2
|
|
dddd d--d 2 2
|
|
drop table t1;
|