Skip to content

Commit

Permalink
Issue percona#67: Inefficient index condition pushdown
Browse files Browse the repository at this point in the history
Summary:
Inside index_next_same() call, we should
1. first check whether the record matches the index
   lookup prefix,
2. then check pushed index condition.

If we try to check percona#2 without checking percona#1 first, we may walk
off the index lookup prefix and scan till the end of the index.

Test Plan: Run mtr

Reviewers: hermanlee4, maykov, jtolmer, yoshinorim

Reviewed By: yoshinorim

Differential Revision: https://reviews.facebook.net/D38769
  • Loading branch information
spetrunia authored and jtolmer committed Jan 5, 2016
1 parent 2143f4a commit 2792667
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mysql-test/suite/rocksdb/r/rocksdb_icp.result
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,37 @@ ROWS_INDEX_NEXT-@rin 0
drop table t4;
drop procedure save_read_stats;
drop procedure get_read_stats;
#
# Issue #67: Inefficient index condition pushdown
#
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1 (
pk int not null primary key,
key1 bigint(20) unsigned,
col1 int,
key (key1)
) engine=rocksdb;
insert into t1
select
A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
1234
from t0 A, t0 B, t0 C;
set @count=0;
explain
select * from t1 where key1=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref key1 key1 9 const 10 Using index condition
set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
select * from t1 where key1=1;
pk key1 col1
1 1 1234
set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
# The following must be =1, or in any case not 999:
select @count_diff as "INTERNAL_KEY_SKIPPED_COUNT increment";
INTERNAL_KEY_SKIPPED_COUNT increment
1
drop table t0,t1;
36 changes: 36 additions & 0 deletions mysql-test/suite/rocksdb/t/rocksdb_icp.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,39 @@ let $cf_name=cf1;

--source suite/rocksdb/t/rocksdb_icp.inc

--echo #
--echo # Issue #67: Inefficient index condition pushdown
--echo #
create table t0 (a int);
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

create table t1 (
pk int not null primary key,
key1 bigint(20) unsigned,
col1 int,
key (key1)
) engine=rocksdb;

insert into t1
select
A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
1234
from t0 A, t0 B, t0 C;

set @count=0;
let $save_query=
set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context
where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');

explain
select * from t1 where key1=1;

eval $save_query;
select * from t1 where key1=1;
eval $save_query;
--echo # The following must be =1, or in any case not 999:
select @count_diff as "INTERNAL_KEY_SKIPPED_COUNT increment";

drop table t0,t1;

0 comments on commit 2792667

Please sign in to comment.