1
drop table if exists t1;
2
create table t1 (a int, index(a)) engine = blitzdb;
3
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
4
insert into t1 values (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
5
insert into t1 values (21),(22),(23),(24),(25),(26),(27),(28),(29),(30);
6
insert into t1 values (31),(32),(33),(34),(35),(36),(37),(38),(39),(40);
7
insert into t1 values (41),(42),(43),(44),(45),(46),(47),(48),(49),(50);
8
insert into t1 values (51),(52),(53),(54),(55),(56),(57),(58),(59),(60);
9
select count(*) from t1;
12
select max(a) from t1;
15
select min(a) from t1;
18
explain select * from t1 where a <= 30;
19
id select_type table type possible_keys key key_len ref rows Extra
20
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
21
select * from t1 where a <= 30;
53
explain select * from t1 where a > 30;
54
id select_type table type possible_keys key key_len ref rows Extra
55
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
56
select * from t1 where a > 30;
88
explain select * from t1 where a <= 10 limit 1;
89
id select_type table type possible_keys key key_len ref rows Extra
90
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
91
select * from t1 where a <= 10 limit 1;
94
explain select * from t1 where a < 20 order by a desc;
95
id select_type table type possible_keys key key_len ref rows Extra
96
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
97
select * from t1 where a < 20 order by a desc;
118
explain select * from t1 where a <= 10 order by a desc limit 1;
119
id select_type table type possible_keys key key_len ref rows Extra
120
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
121
select * from t1 where a <= 10 order by a desc limit 1;
124
explain select * from t1 where a between 30 and 40;
125
id select_type table type possible_keys key key_len ref rows Extra
126
1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
127
select * from t1 where a between 30 and 40;
140
explain select * from t1 where a in (10, 20, 30, 40, 50, 60);
141
id select_type table type possible_keys key key_len ref rows Extra
142
1 SIMPLE t1 range a a 5 NULL 24 Using where; Using index
143
select * from t1 where a in (10, 20, 30, 40, 50, 60);
151
select * from t1 where a > 60;
153
select * from t1 where a < 0;
155
select * from t1 where a > 20 and a < 20;
157
select * from t1 where a is NULL;
160
create table t1 (a bigint, index(a)) engine = blitzdb;
161
insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
162
insert into t1 values (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
163
insert into t1 values (21),(22),(23),(24),(25),(26),(27),(28),(29),(30);
164
insert into t1 values (31),(32),(33),(34),(35),(36),(37),(38),(39),(40);
165
insert into t1 values (41),(42),(43),(44),(45),(46),(47),(48),(49),(50);
166
insert into t1 values (51),(52),(53),(54),(55),(56),(57),(58),(59),(60);
167
explain select * from t1 where a <= 30;
168
id select_type table type possible_keys key key_len ref rows Extra
169
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
170
select * from t1 where a <= 30;
202
explain select * from t1 where a > 30;
203
id select_type table type possible_keys key key_len ref rows Extra
204
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
205
select * from t1 where a > 30;
237
explain select * from t1 where a <= 10 limit 1;
238
id select_type table type possible_keys key key_len ref rows Extra
239
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
240
select * from t1 where a <= 10 limit 1;
243
explain select * from t1 where a < 20 order by a desc;
244
id select_type table type possible_keys key key_len ref rows Extra
245
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
246
select * from t1 where a < 20 order by a desc;
267
select * from t1 where a < 5 order by a desc;
273
explain select * from t1 where a <= 10 order by a desc limit 1;
274
id select_type table type possible_keys key key_len ref rows Extra
275
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
276
select * from t1 where a <= 10 order by a desc limit 1;
279
explain select * from t1 where a between 30 and 40;
280
id select_type table type possible_keys key key_len ref rows Extra
281
1 SIMPLE t1 range a a 9 NULL 4 Using where; Using index
282
select * from t1 where a between 30 and 40;
295
explain select * from t1 where a in (10, 20, 30, 40, 50, 60);
296
id select_type table type possible_keys key key_len ref rows Extra
297
1 SIMPLE t1 range a a 9 NULL 24 Using where; Using index
298
select * from t1 where a in (10, 20, 30, 40, 50, 60);
306
select * from t1 where a > 60;
308
select * from t1 where a < 0;
310
select * from t1 where a > 20 and a < 20;
312
select * from t1 where a is NULL;
315
create table t1 (a double, index(a)) engine = blitzdb;
316
insert into t1 values (1.4), (1.3), (0.9), (1.0), (1.2), (1.1);
325
explain select * from t1;
326
id select_type table type possible_keys key key_len ref rows Extra
327
1 SIMPLE t1 index NULL a 9 NULL 6 Using index
328
select * from t1 where a < 2.0;
336
select * from t1 where a > 0.01;
344
select * from t1 where a <= 1.1;
349
select * from t1 where a > 1.1;
354
select * from t1 where a in (0.9, 1.4, 1.1);
359
select * from t1 where a < 1.3 order by a;
365
select * from t1 where a < 1.3 order by a desc;
371
select * from t1 where a > 2.0;
373
select * from t1 where a < 0.01;
375
select * from t1 where a > 1.0 and a < 1.0;
377
select * from t1 where a is NULL;
380
create table t1 (a date, index(a)) engine = blitzdb;
381
insert into t1 values ('2000-07-10'), ('2000-07-11'), ('2000-07-12');
382
insert into t1 values ('2000-08-13'), ('2000-08-14'), ('2000-08-15');
383
insert into t1 values ('2001-07-10'), ('2001-07-11'), ('2001-07-12');
384
insert into t1 values ('2001-08-13'), ('2001-08-14'), ('2001-08-15');
385
insert into t1 values ('2002-07-10'), ('2002-07-11'), ('2002-07-12');
386
insert into t1 values ('2002-08-13'), ('2002-08-14'), ('2002-08-15');
387
insert into t1 values ('2003-07-10'), ('2003-07-11'), ('2003-07-12');
388
insert into t1 values ('2003-08-13'), ('2003-08-14'), ('2003-08-15');
389
insert into t1 values ('2004-07-10'), ('2004-07-11'), ('2004-07-12');
390
insert into t1 values ('2004-08-13'), ('2004-08-14'), ('2004-08-15');
391
explain select * from t1 where a < '2002-01-01';
392
id select_type table type possible_keys key key_len ref rows Extra
393
1 SIMPLE t1 range a a 4 NULL 4 Using where; Using index
394
select * from t1 where a < '2002-01-01';
408
explain select * from t1 where a between '2002-01-01' and '2002-12-31';
409
id select_type table type possible_keys key key_len ref rows Extra
410
1 SIMPLE t1 range a a 4 NULL 4 Using where; Using index
411
select * from t1 where a between '2002-01-01' and '2002-12-31';
419
explain select * from t1 where a > '2000-01-01' and a < '2004-12-31';
420
id select_type table type possible_keys key key_len ref rows Extra
421
1 SIMPLE t1 range a a 4 NULL 4 Using where; Using index
422
select * from t1 where a > '2000-01-01' and a < '2004-12-31';
454
select count(*) from t1 where a > '2000-01-01' and a < '2004-12-31';
457
explain select * from t1 where a < '2002-07-10' order by a;
458
id select_type table type possible_keys key key_len ref rows Extra
459
1 SIMPLE t1 range a a 4 NULL 4 Using where; Using index
460
select * from t1 where a < '2002-07-10' order by a;
474
explain select * from t1 where a < '2002-07-10' order by a desc;
475
id select_type table type possible_keys key key_len ref rows Extra
476
1 SIMPLE t1 range a a 4 NULL 4 Using where; Using index
477
select * from t1 where a < '2002-07-10' order by a desc;
491
select * from t1 where a > '2022-01-01';
493
select * from t1 where a < '2000-01-01';
495
select count(*) from t1;