Commit 651347b6 authored by Igor Babaev's avatar Igor Babaev

MDEV-16188 Post merge fixes fot TokuDB

parent 6cb2ab53
...@@ -717,11 +717,11 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -717,11 +717,11 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE c_timestamp EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using index condition 1 SIMPLE t1 ALL c_timestamp NULL NULL NULL 20 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03'); IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using index condition 1 SIMPLE t1 ALL c_timestamp NULL NULL NULL 20 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL); EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
......
...@@ -735,12 +735,12 @@ Warnings: ...@@ -735,12 +735,12 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 1 Using where; Using filesort
FLUSH STATUS; FLUSH STATUS;
FLUSH TABLES; FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 1 100.00 Using where; Using filesort
# Status of EXPLAIN EXTENDED query # Status of EXPLAIN EXTENDED query
Variable_name Value Variable_name Value
Handler_read_key 3 Handler_read_key 3
...@@ -764,6 +764,8 @@ Handler_read_rnd_next 1 ...@@ -764,6 +764,8 @@ Handler_read_rnd_next 1
# Status of testing query execution: # Status of testing query execution:
Variable_name Value Variable_name Value
Handler_read_key 3 Handler_read_key 3
Handler_read_rnd_next 1
Sort_scan 1
INSERT INTO t1 VALUES (1), (2), (3), (-1), (-2), (-3); INSERT INTO t1 VALUES (1), (2), (3), (-1), (-2), (-3);
# #
......
...@@ -506,7 +506,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR ...@@ -506,7 +506,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join) 1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1 SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6); (t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
......
...@@ -714,7 +714,7 @@ FieldKey LongVal StringVal ...@@ -714,7 +714,7 @@ FieldKey LongVal StringVal
3 3 3 3 3 3
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 3 Using where 1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 3 Using index condition
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal; SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
FieldKey LongVal StringVal FieldKey LongVal StringVal
3 1 2 3 1 2
......
...@@ -2676,13 +2676,13 @@ explain partitions ...@@ -2676,13 +2676,13 @@ explain partitions
select * from t1 X, t1 Y select * from t1 X, t1 Y
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3); where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where 1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 8 Using where
1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter 1 SIMPLE Y p2,p3 ALL a,b NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
explain partitions explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2); select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where 1 SIMPLE X p1,p2 ALL a NULL NULL NULL 8 Using where
1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2 1 SIMPLE Y p1,p2 ALL a NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
drop table t1; drop table t1;
create table t1 (a int) partition by hash(a) partitions 20; create table t1 (a int) partition by hash(a) partitions 20;
insert into t1 values (1),(2),(3); insert into t1 values (1),(2),(3);
......
...@@ -4748,6 +4748,8 @@ class handler :public Sql_alloc ...@@ -4748,6 +4748,8 @@ class handler :public Sql_alloc
virtual void update_partition(uint part_id) virtual void update_partition(uint part_id)
{} {}
virtual bool is_clustering_key(uint index) { return false; }
protected: protected:
Handler_share *get_ha_share_ptr(); Handler_share *get_ha_share_ptr();
void set_ha_share_ptr(Handler_share *arg_ha_share); void set_ha_share_ptr(Handler_share *arg_ha_share);
......
...@@ -20,10 +20,16 @@ ...@@ -20,10 +20,16 @@
#include "key.h" #include "key.h"
#include "sql_statistics.h" #include "sql_statistics.h"
static ulonglong key_block_no(handler *h, uint keyno, ha_rows keyentry_pos) static ulonglong key_block_no(TABLE *table, uint keyno, ha_rows keyentry_pos)
{ {
return (ulonglong) (h->keyread_time(keyno, 1, keyentry_pos + 1) - size_t len= table->key_info[keyno].key_length + table->file->ref_length;
h->keyread_time(keyno, 0, keyentry_pos + 1) + 0.5) + 1; if (keyno == table->s->primary_key &&
table->file->primary_key_is_clustered())
len= table->s->stored_rec_length;
uint keys_per_block= (uint) (table->file->stats.block_size/2.0/len+1);
ulonglong block_no= !keyentry_pos ? 0 :
(keyentry_pos - 1) / keys_per_block + 1;
return block_no;
} }
/**************************************************************************** /****************************************************************************
...@@ -177,8 +183,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, ...@@ -177,8 +183,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
} }
min_pos+= r - rows; min_pos+= r - rows;
} }
min_block_no= key_block_no(this, keyno, min_pos); min_block_no= key_block_no(this->table, keyno, min_pos);
max_block_no= key_block_no(this, keyno, min_pos + rows); max_block_no= key_block_no(this->table, keyno, min_pos + rows);
new_touched_blocks= max_block_no - min_block_no + new_touched_blocks= max_block_no - min_block_no +
MY_TEST(min_block_no != prev_max_block_no); MY_TEST(min_block_no != prev_max_block_no);
prev_max_block_no= max_block_no; prev_max_block_no= max_block_no;
...@@ -202,7 +208,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, ...@@ -202,7 +208,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
cost->reset(); cost->reset();
cost->avg_io_cost= 1; /* assume random seeks */ cost->avg_io_cost= 1; /* assume random seeks */
cost->idx_avg_io_cost= 1; cost->idx_avg_io_cost= 1;
if (!(keyno == table->s->primary_key && primary_key_is_clustered())) if (!((keyno == table->s->primary_key && primary_key_is_clustered()) ||
is_clustering_key(keyno)))
{ {
cost->idx_io_count= total_touched_blocks + cost->idx_io_count= total_touched_blocks +
keyread_time(keyno, 0, total_rows); keyread_time(keyno, 0, total_rows);
......
...@@ -7775,13 +7775,18 @@ double ha_tokudb::scan_time() { ...@@ -7775,13 +7775,18 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val); DBUG_RETURN(ret_val);
} }
bool ha_tokudb::is_clustering_key(uint index)
{
return index == primary_key || key_is_clustering(&table->key_info[index]);
}
double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows) double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
{ {
TOKUDB_HANDLER_DBUG_ENTER("%u %u %" PRIu64, index, ranges, (uint64_t) rows); TOKUDB_HANDLER_DBUG_ENTER("%u %u %" PRIu64, index, ranges, (uint64_t) rows);
double ret_val; double cost;
if (index == primary_key || key_is_clustering(&table->key_info[index])) { if (index == primary_key || is_clustering_key(index)) {
ret_val = read_time(index, ranges, rows); cost = read_time(index, ranges, rows);
DBUG_RETURN(ret_val); DBUG_RETURN(cost);
} }
/* /*
It is assumed that we will read trough the whole key range and that all It is assumed that we will read trough the whole key range and that all
...@@ -7791,11 +7796,8 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows) ...@@ -7791,11 +7796,8 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
blocks read. This model does not take into account clustered indexes - blocks read. This model does not take into account clustered indexes -
engines that support that (e.g. InnoDB) may want to overwrite this method. engines that support that (e.g. InnoDB) may want to overwrite this method.
*/ */
double keys_per_block= (stats.block_size/2.0/ cost= handler::keyread_time(index, ranges, rows);
(table->key_info[index].key_length + TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(cost);
ref_length) + 1);
ret_val = (rows + keys_per_block - 1)/ keys_per_block;
TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val);
} }
// //
......
...@@ -871,6 +871,7 @@ class ha_tokudb : public handler { ...@@ -871,6 +871,7 @@ class ha_tokudb : public handler {
bool primary_key_is_clustered() { bool primary_key_is_clustered() {
return true; return true;
} }
bool is_clustering_key(uint index);
int cmp_ref(const uchar * ref1, const uchar * ref2); int cmp_ref(const uchar * ref1, const uchar * ref2);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes); bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
......
# test for TokuDB clustering keys. # test for TokuDB clustering keys.
# test assumes that a table 't1' exists with the following columns: # test assumes that a table 't1' exists with the following columns:
# a int, b int, c int, d int # a int, b int, c int, d int
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries #normal queries
...@@ -13,20 +16,20 @@ select * from t1 where a > 5; ...@@ -13,20 +16,20 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
select a from t1 where a > 8; select a from t1 where a > 10;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
...@@ -35,8 +38,8 @@ select a,b from t1 where b > 30; ...@@ -35,8 +38,8 @@ select a,b from t1 where b > 30;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 350;
select a,c from t1 where c > 750; select a,c from t1 where c > 350;
alter table t1 add index bdca(b,d,c,a) clustering=yes; alter table t1 add index bdca(b,d,c,a) clustering=yes;
...@@ -51,25 +54,25 @@ select * from t1 where a > 5; ...@@ -51,25 +54,25 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select b from t1 where b > 30; explain select b from t1 where b > 70;
select b from t1 where b > 30; select b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select b from t1 where c > 750; explain select b from t1 where c > 950;
select c from t1 where c > 750; select c from t1 where c > 950;
alter table t1 add e varchar(20); alter table t1 add e varchar(20);
...@@ -77,25 +80,25 @@ alter table t1 add primary key (a,b,c); ...@@ -77,25 +80,25 @@ alter table t1 add primary key (a,b,c);
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where a > 5; explain select * from t1 where a > 8;
select * from t1 where a > 5; select * from t1 where a > 8;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
select a from t1 where a > 8; select a from t1 where a > 10;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
...@@ -104,8 +107,8 @@ select a,b from t1 where b > 30; ...@@ -104,8 +107,8 @@ select a,b from t1 where b > 30;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 350;
select a,c from t1 where c > 750; select a,c from t1 where c > 350;
alter table t1 drop primary key; alter table t1 drop primary key;
...@@ -116,23 +119,23 @@ select * from t1 where a > 5; ...@@ -116,23 +119,23 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select b from t1 where b > 30; explain select b from t1 where b > 70;
select b from t1 where b > 30; select b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select b from t1 where c > 750; explain select b from t1 where c > 950;
select c from t1 where c > 750; select c from t1 where c > 950;
...@@ -1096,7 +1096,7 @@ t CREATE TABLE `t` ( ...@@ -1096,7 +1096,7 @@ t CREATE TABLE `t` (
explain select straight_join s.a,t.a from s,t where s.b = t.b; explain select straight_join s.a,t.a from s,t where s.b = t.b;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index 1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index
1 SIMPLE t ref b,b_2,b_3 b_2 5 test.s.b 1 Using index 1 SIMPLE t ref b,b_2,b_3 b_3 5 test.s.b 1 Using index
alter table s drop key b_2; alter table s drop key b_2;
alter table t drop key b_2; alter table t drop key b_2;
show create table s; show create table s;
......
...@@ -39,16 +39,20 @@ t1 CREATE TABLE `t1` ( ...@@ -39,16 +39,20 @@ t1 CREATE TABLE `t1` (
KEY `foo` (`c`,`d`) `clustering`=yes, KEY `foo` (`c`,`d`) `clustering`=yes,
KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes
) ENGINE=TokuDB DEFAULT CHARSET=latin1 ) ENGINE=TokuDB DEFAULT CHARSET=latin1
insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56); insert into t1 value
(1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
(32,54,12,56);
explain select * from t1; explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 16 NULL 5 Using index 1 SIMPLE t1 index NULL PRIMARY 16 NULL 7 Using index
select * from t1; select * from t1;
a b c d a b c d
1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4
5 5 5 5
6 6 6 6
32 54 12 56 32 54 12 56
explain select d from t1 where d > 30; explain select d from t1 where d > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
......
SET DEFAULT_STORAGE_ENGINE='tokudb'; SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
...@@ -11,48 +14,47 @@ a b c d ...@@ -11,48 +14,47 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where b > 30; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where c > 750; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 850;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 850;
a b c d a b c d
8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select a from t1 where a > 8; 10 100 1000 10000
11 110 1100 11000
explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 10;
a a
9 11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
a b a b
4 40
5 50
6 60
7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
a c a c
8 800 10 1000
9 900 11 1100
delete from t1 where b>30 and b < 60; delete from t1 where b>30 and b < 60;
select * from t1; select * from t1;
a b c d a b c d
...@@ -63,15 +65,16 @@ a b c d ...@@ -63,15 +65,16 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where a > 5; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
select * from t1 where a > 5; select * from t1 where a > 8;
a b c d a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 30; explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
...@@ -81,19 +84,25 @@ a b c d ...@@ -81,19 +84,25 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 750; explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 750;
a b c d a b c d
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select a from t1 where a > 8; explain select a from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 index PRIMARY c 5 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 8;
a a
9 9
10
11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
...@@ -103,13 +112,14 @@ a b ...@@ -103,13 +112,14 @@ a b
7 70 7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 1050;
a c a c
8 800 11 1100
9 900
alter table t1 drop primary key; alter table t1 drop primary key;
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -120,22 +130,23 @@ a b c d ...@@ -120,22 +130,23 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where b > 30; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
6 60 600 6000
7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where c > 750; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 1050;
a b c d a b c d
8 80 800 8000 11 110 1100 11000
9 90 900 9000
explain select a from t1 where a > 5; explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
...@@ -145,61 +156,76 @@ a ...@@ -145,61 +156,76 @@ a
7 7
8 8
9 9
explain select a,b from t1 where b > 30; 10
11
explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
a b a b
6 60
7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 1050;
a c a c
8 800 11 1100
9 900
delete from t1 where b > 10 and b < 90; delete from t1 where b > 10 and b < 90;
select * from t1; select * from t1;
a b c d a b c d
1 10 100 1000 1 10 100 1000
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select * from t1 where a > 5; select * from t1 where a > 5;
a b c d a b c d
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 30; explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 30;
a b c d a b c d
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 750; explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 750;
a b c d a b c d
9 90 900 9000 9 90 900 9000
10 100 1000 10000
11 110 1100 11000
explain select a from t1 where a > 5; explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select a from t1 where a > 5; select a from t1 where a > 5;
a a
9 9
10
11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30; select a,b from t1 where b > 30;
a b a b
9 90 9 90
10 100
11 110
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 750;
a c a c
9 900 9 900
10 1000
11 1100
drop table t1; drop table t1;
...@@ -7,22 +7,19 @@ insert into t1 values (2,"20",200); ...@@ -7,22 +7,19 @@ insert into t1 values (2,"20",200);
insert into t1 values (3,"30",300); insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400); insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500); insert into t1 values (5,"50",500);
explain select * from t1 where a > 2; explain select * from t1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 3 Using where 1 SIMPLE t1 range a a 5 NULL 2 Using where
select * from t1 where a > 2; select * from t1 where a > 3;
a b c a b c
3 30 300
4 40 400 4 40 400
5 50 500 5 50 500
select b from t1 where a > 2; select b from t1 where a > 3;
b b
30
40 40
50 50
select c from t1 where a > 2; select c from t1 where a > 3;
c c
300
400 400
500 500
delete from t1 where a <2; delete from t1 where a <2;
......
SET DEFAULT_STORAGE_ENGINE='tokudb'; SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
...@@ -11,30 +14,30 @@ a b c d ...@@ -11,30 +14,30 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where b > 30; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where c > 750; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d a b c d
8 80 800 8000 10 100 1000 10000
9 90 900 9000 11 110 1100 11000
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 10;
a a
9 11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index 1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
...@@ -46,13 +49,21 @@ a b ...@@ -46,13 +49,21 @@ a b
7 70 7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index 1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
select a,c from t1 where c > 750; select a,c from t1 where c > 350;
a c a c
4 400
5 500
6 600
7 700
8 800 8 800
9 900 9 900
10 1000
11 1100
alter table t1 add index bdca(b,d,c,a) clustering=yes; alter table t1 add index bdca(b,d,c,a) clustering=yes;
insert into t1 values (10,10,10,10); insert into t1 values (10,10,10,10);
alter table t1 drop index bdca; alter table t1 drop index bdca;
...@@ -67,79 +78,73 @@ a b c d ...@@ -67,79 +78,73 @@ a b c d
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
10 10 10 10 10 10 10 10
explain select * from t1 where b > 30; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where c > 750; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d a b c d
8 80 800 8000 10 100 1000 10000
9 90 900 9000 11 110 1100 11000
explain select b from t1 where b > 30; explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select b from t1 where b > 30; select b from t1 where b > 70;
b b
40
50
60
70
80 80
90 90
explain select b from t1 where c > 750; 100
110
explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select c from t1 where c > 750; select c from t1 where c > 950;
c c
800 1000
900 1100
alter table t1 add e varchar(20); alter table t1 add e varchar(20);
alter table t1 add primary key (a,b,c); alter table t1 add primary key (a,b,c);
explain select * from t1 where a > 5; explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
select * from t1 where a > 5; select * from t1 where a > 8;
a b c d e a b c d e
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL 9 90 900 9000 NULL
10 10 10 10 NULL 10 10 10 10 NULL
explain select * from t1 where b > 30; 10 100 1000 10000 NULL
11 110 1100 11000 NULL
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d e a b c d e
4 40 400 4000 NULL
5 50 500 5000 NULL
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL 8 80 800 8000 NULL
9 90 900 9000 NULL 9 90 900 9000 NULL
explain select * from t1 where c > 750; 10 100 1000 10000 NULL
11 110 1100 11000 NULL
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d e a b c d e
8 80 800 8000 NULL 10 100 1000 10000 NULL
9 90 900 9000 NULL 11 110 1100 11000 NULL
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 10;
a a
9 11
10
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index 1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
...@@ -151,13 +156,21 @@ a b ...@@ -151,13 +156,21 @@ a b
7 70 7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index 1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
select a,c from t1 where c > 750; select a,c from t1 where c > 350;
a c a c
4 400
5 500
6 600
7 700
8 800 8 800
9 900 9 900
10 1000
11 1100
alter table t1 drop primary key; alter table t1 drop primary key;
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -169,40 +182,38 @@ a b c d e ...@@ -169,40 +182,38 @@ a b c d e
8 80 800 8000 NULL 8 80 800 8000 NULL
9 90 900 9000 NULL 9 90 900 9000 NULL
10 10 10 10 NULL 10 10 10 10 NULL
explain select * from t1 where b > 30; 10 100 1000 10000 NULL
11 110 1100 11000 NULL
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d e a b c d e
4 40 400 4000 NULL
5 50 500 5000 NULL
6 60 600 6000 NULL
7 70 700 7000 NULL
8 80 800 8000 NULL 8 80 800 8000 NULL
9 90 900 9000 NULL 9 90 900 9000 NULL
explain select * from t1 where c > 750; 10 100 1000 10000 NULL
11 110 1100 11000 NULL
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d e a b c d e
8 80 800 8000 NULL 10 100 1000 10000 NULL
9 90 900 9000 NULL 11 110 1100 11000 NULL
explain select b from t1 where b > 30; explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
select b from t1 where b > 30; select b from t1 where b > 70;
b b
40
50
60
70
80 80
90 90
explain select b from t1 where c > 750; 100
110
explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where 1 SIMPLE t1 range c c 4 NULL NULL; Using where
select c from t1 where c > 750; select c from t1 where c > 950;
c c
800 1000
900 1100
drop table t1; drop table t1;
...@@ -2,16 +2,16 @@ SET DEFAULT_STORAGE_ENGINE='tokudb'; ...@@ -2,16 +2,16 @@ SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9); insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
explain select * from t1 where b > 2; explain select * from t1 where b > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
explain select * from t1 where c > 2; explain select * from t1 where c > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
explain select * from t1 where a > 4; explain select * from t1 where a > 7;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
explain select * from t1 where c > 7; explain select * from t1 where c > 8;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
explain select * from t1 where b > 7; explain select * from t1 where b > 7;
......
...@@ -32,13 +32,13 @@ max(a) ...@@ -32,13 +32,13 @@ max(a)
7 7
explain select a,b from z1 where a < 7; explain select a,b from z1 where a < 7;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 12 Using where; Using index 1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 7; select max(a) from z1 where a < 7;
max(a) max(a)
3 3
explain select a,b from z1 where a < 3; explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index 1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 3; select max(a) from z1 where a < 3;
max(a) max(a)
1 1
......
SET DEFAULT_STORAGE_ENGINE='tokudb'; SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
...@@ -11,48 +14,48 @@ a b c d ...@@ -11,48 +14,48 @@ a b c d
7 70 700 7000 7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where b > 30; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
4 40 400 4000
5 50 500 5000
6 60 600 6000
7 70 700 7000
8 80 800 8000 8 80 800 8000
9 90 900 9000 9 90 900 9000
explain select * from t1 where c > 750; 10 100 1000 10000
11 110 1100 11000
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d a b c d
8 80 800 8000 10 100 1000 10000
9 90 900 9000 11 110 1100 11000
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 8;
a a
9 9
explain select a,b from t1 where b > 30; 10
11
explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
a b a b
4 40
5 50
6 60
7 70
8 80 8 80
9 90 9 90
explain select a,b from t1 where c > 750; 10 100
11 110
explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
a c a c
8 800 10 1000
9 900 11 1100
update t1 set c = c+5, b = b+5 where b>30; update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -63,6 +66,8 @@ a b c d ...@@ -63,6 +66,8 @@ a b c d
7 75 705 7000 7 75 705 7000
8 85 805 8000 8 85 805 8000
9 95 905 9000 9 95 905 9000
10 105 1005 10000
11 115 1105 11000
explain select * from t1 where b > 30; explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
...@@ -74,6 +79,8 @@ a b c d ...@@ -74,6 +79,8 @@ a b c d
7 75 705 7000 7 75 705 7000
8 85 805 8000 8 85 805 8000
9 95 905 9000 9 95 905 9000
10 105 1005 10000
11 115 1105 11000
explain select * from t1 where c > 750; explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
...@@ -81,12 +88,14 @@ select * from t1 where c > 750; ...@@ -81,12 +88,14 @@ select * from t1 where c > 750;
a b c d a b c d
8 85 805 8000 8 85 805 8000
9 95 905 9000 9 95 905 9000
explain select a from t1 where a > 8; 10 105 1005 10000
11 115 1105 11000
explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8; select a from t1 where a > 10;
a a
9 11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NA b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 NA b b 5 NULL NULL; Using where; Using index
...@@ -98,6 +107,8 @@ a b ...@@ -98,6 +107,8 @@ a b
7 75 7 75
8 85 8 85
9 95 9 95
10 105
11 115
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
...@@ -105,6 +116,8 @@ select a,c from t1 where c > 750; ...@@ -105,6 +116,8 @@ select a,c from t1 where c > 750;
a c a c
8 805 8 805
9 905 9 905
10 1005
11 1105
alter table t1 drop primary key; alter table t1 drop primary key;
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
...@@ -115,24 +128,25 @@ a b c d ...@@ -115,24 +128,25 @@ a b c d
7 75 705 7000 7 75 705 7000
8 85 805 8000 8 85 805 8000
9 95 905 9000 9 95 905 9000
explain select * from t1 where b > 30; 10 105 1005 10000
11 115 1105 11000
explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30; select * from t1 where b > 70;
a b c d a b c d
4 45 405 4000
5 55 505 5000
6 65 605 6000
7 75 705 7000 7 75 705 7000
8 85 805 8000 8 85 805 8000
9 95 905 9000 9 95 905 9000
explain select * from t1 where c > 750; 10 105 1005 10000
11 115 1105 11000
explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select * from t1 where c > 750; select * from t1 where c > 950;
a b c d a b c d
8 85 805 8000 10 105 1005 10000
9 95 905 9000 11 115 1105 11000
explain select a from t1 where a > 5; explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
...@@ -142,24 +156,25 @@ a ...@@ -142,24 +156,25 @@ a
7 7
8 8
9 9
explain select a,b from t1 where b > 30; 10
11
explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
a b a b
4 45
5 55
6 65
7 75 7 75
8 85 8 85
9 95 9 95
explain select a,b from t1 where c > 750; 10 105
11 115
explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where 1 SIMPLE t1 range c c 5 NULL NULL; Using where
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
a c a c
8 805 10 1005
9 905 11 1105
update t1 set c = c+5, b = b+5 where b>30; update t1 set c = c+5, b = b+5 where b>30;
select * from t1; select * from t1;
a b c d a b c d
...@@ -172,6 +187,8 @@ a b c d ...@@ -172,6 +187,8 @@ a b c d
7 80 710 7000 7 80 710 7000
8 90 810 8000 8 90 810 8000
9 100 910 9000 9 100 910 9000
10 110 1010 10000
11 120 1110 11000
explain select * from t1 where a > 5; explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
...@@ -181,6 +198,8 @@ a b c d ...@@ -181,6 +198,8 @@ a b c d
7 80 710 7000 7 80 710 7000
8 90 810 8000 8 90 810 8000
9 100 910 9000 9 100 910 9000
10 110 1010 10000
11 120 1110 11000
explain select * from t1 where b > 30; explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
...@@ -192,6 +211,8 @@ a b c d ...@@ -192,6 +211,8 @@ a b c d
7 80 710 7000 7 80 710 7000
8 90 810 8000 8 90 810 8000
9 100 910 9000 9 100 910 9000
10 110 1010 10000
11 120 1110 11000
explain select * from t1 where c > 750; explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
...@@ -199,6 +220,8 @@ select * from t1 where c > 750; ...@@ -199,6 +220,8 @@ select * from t1 where c > 750;
a b c d a b c d
8 90 810 8000 8 90 810 8000
9 100 910 9000 9 100 910 9000
10 110 1010 10000
11 120 1110 11000
explain select a from t1 where a > 5; explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
...@@ -208,6 +231,8 @@ a ...@@ -208,6 +231,8 @@ a
7 7
8 8
9 9
10
11
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index 1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
...@@ -219,6 +244,8 @@ a b ...@@ -219,6 +244,8 @@ a b
7 80 7 80
8 90 8 90
9 100 9 100
10 110
11 120
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where 1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
...@@ -226,4 +253,6 @@ select a,c from t1 where c > 750; ...@@ -226,4 +253,6 @@ select a,c from t1 where c > 750;
a c a c
8 810 8 810
9 910 9 910
10 1010
11 1110
drop table t1; drop table t1;
drop table if exists t; drop table if exists t;
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb; create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4); insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0; explain select x,id from t force index (x) where x=0 and id=0;
......
drop table if exists t; drop table if exists t;
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb; create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4); insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0; explain select x,id from t force index (x) where x=0 and id=0;
......
drop table if exists t; drop table if exists t;
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb; create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
insert into t values (0,0,0,0),(0,1,0,1); insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1; explain select c,a,b from t where c=0 and a=0 and b=1;
......
drop table if exists t; drop table if exists t;
select @@optimizer_switch; select @@optimizer_switch;
@@optimizer_switch @@optimizer_switch
index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb; create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
insert into t values (0,0,0,0),(0,1,0,1); insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1; explain select c,a,b from t where c=0 and a=0 and b=1;
......
...@@ -31,7 +31,7 @@ delete from foo where a > 5; ...@@ -31,7 +31,7 @@ delete from foo where a > 5;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a > 1; explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a > 1; select * from foo where a > 1;
a b a b
...@@ -43,7 +43,7 @@ connection conn1; ...@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a > 1; explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values # 9 values
select * From foo where a > 1; select * From foo where a > 1;
a b a b
......
...@@ -31,7 +31,7 @@ delete from foo where a < 10; ...@@ -31,7 +31,7 @@ delete from foo where a < 10;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a < 50; explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a < 50; select * from foo where a < 50;
a b a b
...@@ -43,7 +43,7 @@ connection conn1; ...@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9 # number of rows should be 9
explain select * from foo where a < 50; explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values # 9 values
select * From foo where a < 50; select * From foo where a < 50;
a b a b
......
...@@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50; ...@@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8 # number of rows should be 8
explain select * from foo where a > 1 and a < 50; explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values # should have just 4 values
select * from foo where a > 1 and a < 50; select * from foo where a > 1 and a < 50;
a b a b
...@@ -43,7 +43,7 @@ connection conn1; ...@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 8 # number of rows should be 8
explain select * from foo where a > 1 and a < 50; explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where 1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 8 values # 8 values
select * from foo where a > 1 and a < 50; select * from foo where a > 1 and a < 50;
a b a b
......
...@@ -305,25 +305,25 @@ dummy INT PRIMARY KEY, ...@@ -305,25 +305,25 @@ dummy INT PRIMARY KEY,
a INT UNIQUE, a INT UNIQUE,
b INT b INT
) ENGINE=TokuDB; ) ENGINE=TokuDB;
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT; COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation; SELECT @@tx_isolation;
@@tx_isolation @@tx_isolation
REPEATABLE-READ REPEATABLE-READ
START TRANSACTION; START TRANSACTION;
EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE; EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where 1 SIMPLE t1 range a a 5 NULL 2 Using where
SELECT * FROM t1 WHERE a >= 2 FOR UPDATE; SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
dummy a b dummy a b
3 3 3 8 8 8
5 5 5 9 9 9
connection con2; connection con2;
SET AUTOCOMMIT=0; SET AUTOCOMMIT=0;
SET TOKUDB_LOCK_TIMEOUT=2; SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION; START TRANSACTION;
INSERT INTO t1 VALUES (2,2,2); INSERT INTO t1 VALUES (8,8,8);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK; ROLLBACK;
connection con1; connection con1;
......
...@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b)); ...@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0); INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2; EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort 1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
DROP TABLE t1; DROP TABLE t1;
End of 5.0 tests End of 5.0 tests
create table t1(a bit(7)); create table t1(a bit(7));
......
...@@ -667,14 +667,14 @@ id txt ...@@ -667,14 +667,14 @@ id txt
alter table t1 modify column txt blob; alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL; explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where 1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
select * from t1 where txt='Chevy' or txt is NULL; select * from t1 where txt='Chevy' or txt is NULL;
id txt id txt
1 Chevy 1 Chevy
3 NULL 3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL order by txt; explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where; Using filesort 1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort
select * from t1 where txt='Chevy' or txt is NULL order by txt; select * from t1 where txt='Chevy' or txt is NULL order by txt;
id txt id txt
3 NULL 3 NULL
......
...@@ -22,7 +22,9 @@ alter table t1 drop primary key; ...@@ -22,7 +22,9 @@ alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d); alter table t1 add primary key (a,b,c,d);
alter table t1 add key bar(d,c,b,a) clustering=yes; alter table t1 add key bar(d,c,b,a) clustering=yes;
show create table t1; show create table t1;
insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56); insert into t1 value
(1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
(32,54,12,56);
explain select * from t1; explain select * from t1;
select * from t1; select * from t1;
explain select d from t1 where d > 30; explain select d from t1 where d > 30;
......
...@@ -7,8 +7,10 @@ DROP TABLE IF EXISTS t1; ...@@ -7,8 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries #normal queries
...@@ -19,38 +21,38 @@ select * from t1 where a > 5; ...@@ -19,38 +21,38 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 850;
select * from t1 where c > 750; select * from t1 where c > 850;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
select a from t1 where a > 8; select a from t1 where a > 10;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 70;
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 950;
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
delete from t1 where b>30 and b < 60; delete from t1 where b>30 and b < 60;
select * from t1; select * from t1;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where a > 5; explain select * from t1 where a > 8;
select * from t1 where a > 5; select * from t1 where a > 8;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
...@@ -76,8 +78,8 @@ select a,b from t1 where b > 30; ...@@ -76,8 +78,8 @@ select a,b from t1 where b > 30;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 1050;
select a,c from t1 where c > 750; select a,c from t1 where c > 1050;
alter table t1 drop primary key; alter table t1 drop primary key;
...@@ -88,13 +90,13 @@ select * from t1 where a > 5; ...@@ -88,13 +90,13 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 1050;
select * from t1 where c > 750; select * from t1 where c > 1050;
#covering indexes #covering indexes
...@@ -105,13 +107,13 @@ select a from t1 where a > 5; ...@@ -105,13 +107,13 @@ select a from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 70;
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 1050;
select a,c from t1 where c > 750; select a,c from t1 where c > 1050;
delete from t1 where b > 10 and b < 90; delete from t1 where b > 10 and b < 90;
......
...@@ -13,10 +13,10 @@ insert into t1 values (3,"30",300); ...@@ -13,10 +13,10 @@ insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400); insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500); insert into t1 values (5,"50",500);
explain select * from t1 where a > 2; explain select * from t1 where a > 3;
select * from t1 where a > 2; select * from t1 where a > 3;
select b from t1 where a > 2; select b from t1 where a > 3;
select c from t1 where a > 2; select c from t1 where a > 3;
#explain delete from t1 where a <2; #explain delete from t1 where a <2;
delete from t1 where a <2; delete from t1 where a <2;
......
...@@ -11,18 +11,18 @@ insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6 ...@@ -11,18 +11,18 @@ insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 2; explain select * from t1 where b > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 2; explain select * from t1 where c > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where a > 4; explain select * from t1 where a > 7;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 7; explain select * from t1 where c > 8;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 7; explain select * from t1 where b > 7;
......
...@@ -7,7 +7,10 @@ DROP TABLE IF EXISTS t1; ...@@ -7,7 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb; create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000); insert into t1 values
(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries #normal queries
...@@ -19,30 +22,30 @@ select * from t1 where a > 5; ...@@ -19,30 +22,30 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
select a from t1 where a > 8; select a from t1 where a > 8;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 70;
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 950;
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30; update t1 set c = c+5, b = b+5 where b>30;
...@@ -64,8 +67,8 @@ select * from t1 where c > 750; ...@@ -64,8 +67,8 @@ select * from t1 where c > 750;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a from t1 where a > 8; explain select a from t1 where a > 10;
select a from t1 where a > 8; select a from t1 where a > 10;
# ignore rows column # ignore rows column
--replace_column 4 NA 9 NULL; --replace_column 4 NA 9 NULL;
...@@ -86,13 +89,13 @@ select * from t1 where a > 5; ...@@ -86,13 +89,13 @@ select * from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where b > 30; explain select * from t1 where b > 70;
select * from t1 where b > 30; select * from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select * from t1 where c > 750; explain select * from t1 where c > 950;
select * from t1 where c > 750; select * from t1 where c > 950;
#covering indexes #covering indexes
# ignore rows column # ignore rows column
...@@ -102,13 +105,13 @@ select a from t1 where a > 5; ...@@ -102,13 +105,13 @@ select a from t1 where a > 5;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where b > 30; explain select a,b from t1 where b > 70;
select a,b from t1 where b > 30; select a,b from t1 where b > 70;
# ignore rows column # ignore rows column
--replace_column 9 NULL; --replace_column 9 NULL;
explain select a,b from t1 where c > 750; explain select a,b from t1 where c > 950;
select a,c from t1 where c > 750; select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30; update t1 set c = c+5, b = b+5 where b>30;
select * from t1; select * from t1;
......
...@@ -40,16 +40,16 @@ CREATE TABLE t1 ( ...@@ -40,16 +40,16 @@ CREATE TABLE t1 (
b INT b INT
) ENGINE=TokuDB; ) ENGINE=TokuDB;
INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5); INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT; COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation; SELECT @@tx_isolation;
START TRANSACTION; START TRANSACTION;
EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE; EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
SELECT * FROM t1 WHERE a >= 2 FOR UPDATE; SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
connection con2; connection con2;
...@@ -58,7 +58,7 @@ SET TOKUDB_LOCK_TIMEOUT=2; ...@@ -58,7 +58,7 @@ SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION; START TRANSACTION;
--error ER_LOCK_WAIT_TIMEOUT --error ER_LOCK_WAIT_TIMEOUT
INSERT INTO t1 VALUES (2,2,2); INSERT INTO t1 VALUES (8,8,8);
ROLLBACK; ROLLBACK;
connection con1; connection con1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment