Created
August 8, 2020 00:52
-
-
Save mdcallag/6e7a8ab51fd779ff3d2e6c592c1e1a2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists t; | |
create table t (x int not null, y int not null, z int not null, val int not null, bloat char(200) not null); | |
create index x1 on t(x, y, z); | |
drop table if exists t2; | |
create table t2 (x int, y int, z int, val int, bloat char(200)); | |
insert into t2 (x,y,z,val,bloat) values (1,1,1,1,"a1"), (1,2,2,2,"a2"), (1,3,3,3,"a3"), (1,4,4,4,"a4"), (1,5,5,5,"a5"), (1,6,6,6,"a6"), (1,7,7,7,"a7"), (1,8,8,8,"a8"), (1,9,9,9,"a9"), (1,10,10,10,"a10"); | |
insert into t (x,y,z,val,bloat) select 1, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 2, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 3, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 4, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 5, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 6, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 7, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 8, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 9, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 10, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 11, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 12, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 13, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 14, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 15, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 16, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 17, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 18, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 19, y, z, val, bloat from t2; | |
insert into t (x,y,z,val,bloat) select 20, y, z, val, bloat from t2; | |
analyze table t; | |
select count(*) from t where x in (1,2,3) and y = 3 and z in (1,3,5); | |
select count(*) from t where x in (1,2,3) and y = 3; | |
select count(*) from t where x in (1,2,3); | |
explain select * from t where x in (1,2,3) and y = 3 and z in (1,3,5)\G | |
explain select * from t where x in (1,2,3) and y = 3\G | |
explain select * from t where x in (1,2,3)\G | |
explain select * from t where x >= 1 and x <= 3 and y = 3 and z in (1,3,5)\G | |
explain select * from t where x >= 1 and x <= 3 and y = 3\G | |
explain select * from t where x >= 1 and x <= 3\G | |
select * from t where x in (1,2,3) and y = 3 and z in (1,3,5); | |
select * from t where x in (1,2,3) and y = 3; | |
select * from t where x in (1,2,3); | |
select * from t where x >= 1 and x <= 3 and y = 3 and z in (1,3,5); | |
select * from t where x >= 1 and x <= 3 and y = 3; | |
select * from t where x >= 1 and x <= 3; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment