Commit 520d2063 authored by Sergei Petrunia's avatar Sergei Petrunia

MariaRocks port: get rocksdb.rocksdb_icp[_rev] to work

- Fix the test cases to not use userstat counters specific to
  facebook/mysql-5.6
- Make testcase also check MariaDB's ICP counters
- Remove ha_rocksdb::check_index_cond(), call handler_index_cond_check
  instead.
parent 93d3a39b
...@@ -6795,7 +6795,7 @@ int ha_rocksdb::find_icp_matching_index_rec(const bool &move_forward, ...@@ -6795,7 +6795,7 @@ int ha_rocksdb::find_icp_matching_index_rec(const bool &move_forward,
return HA_ERR_INTERNAL_ERROR; return HA_ERR_INTERNAL_ERROR;
} }
const enum icp_result icp_status= check_index_cond(); const enum icp_result icp_status= handler_index_cond_check(this);
if (icp_status == ICP_NO_MATCH) if (icp_status == ICP_NO_MATCH)
{ {
if (move_forward) if (move_forward)
...@@ -6804,7 +6804,7 @@ int ha_rocksdb::find_icp_matching_index_rec(const bool &move_forward, ...@@ -6804,7 +6804,7 @@ int ha_rocksdb::find_icp_matching_index_rec(const bool &move_forward,
m_scan_it->Prev(); m_scan_it->Prev();
continue; /* Get the next (or prev) index tuple */ continue; /* Get the next (or prev) index tuple */
} }
else if (icp_status == ICP_OUT_OF_RANGE) else if (icp_status == ICP_OUT_OF_RANGE || icp_status == ICP_ABORTED_BY_USER)
{ {
/* We have walked out of range we are scanning */ /* We have walked out of range we are scanning */
table->status= STATUS_NOT_FOUND; table->status= STATUS_NOT_FOUND;
...@@ -9951,41 +9951,6 @@ class Item* ha_rocksdb::idx_cond_push(uint keyno, class Item* const idx_cond) ...@@ -9951,41 +9951,6 @@ class Item* ha_rocksdb::idx_cond_push(uint keyno, class Item* const idx_cond)
} }
/*
@brief
Check the index condition.
@detail
Check the index condition. (The caller has unpacked all needed index
columns into table->record[0])
@return
ICP_NO_MATCH - Condition not satisfied (caller should continue
scanning)
OUT_OF_RANGE - We've left the range we're scanning (caller should
stop scanning and return HA_ERR_END_OF_FILE)
ICP_MATCH - Condition is satisfied (caller should fetch the record
and return it)
*/
enum icp_result ha_rocksdb::check_index_cond() const
{
DBUG_ASSERT(pushed_idx_cond);
DBUG_ASSERT(pushed_idx_cond_keyno != MAX_KEY);
// MARIAROCKS_NOT_YET: MariaRocks todo: switch to using
// handler_index_cond_check() call?
if (end_range && compare_key2(end_range) > 0)
{
/* caller should return HA_ERR_END_OF_FILE already */
return ICP_OUT_OF_RANGE;
}
return pushed_idx_cond->val_int() ? ICP_MATCH : ICP_NO_MATCH;
}
/** /**
Checking if an index is used for ascending scan or not Checking if an index is used for ascending scan or not
......
...@@ -855,7 +855,6 @@ class ha_rocksdb: public my_core::handler ...@@ -855,7 +855,6 @@ class ha_rocksdb: public my_core::handler
int index_last_intern(uchar *buf) int index_last_intern(uchar *buf)
__attribute__((__nonnull__, __warn_unused_result__)); __attribute__((__nonnull__, __warn_unused_result__));
enum icp_result check_index_cond() const;
int find_icp_matching_index_rec(const bool &move_forward, uchar* const buf) int find_icp_matching_index_rec(const bool &move_forward, uchar* const buf)
__attribute__((__nonnull__, __warn_unused_result__)); __attribute__((__nonnull__, __warn_unused_result__));
......
...@@ -66,6 +66,8 @@ select * from t2 where kp1< 3 and kp2+1>50000; ...@@ -66,6 +66,8 @@ select * from t2 where kp1< 3 and kp2+1>50000;
select * from t2 where kp1< 3 and kp2+1>50000; select * from t2 where kp1< 3 and kp2+1>50000;
--echo # Try doing backwards scans --echo # Try doing backwards scans
--echo # MariaDB: ICP is not supported for reverse scans.
--replace_column 9 # --replace_column 9 #
explain explain
select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
...@@ -88,17 +90,60 @@ drop table t0,t1,t2,t3; ...@@ -88,17 +90,60 @@ drop table t0,t1,t2,t3;
--echo # --echo #
--echo # First, some preparations --echo # First, some preparations
--echo # --echo #
--echo # in facebook/mysql-5.6, it was:
--echo # select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
--echo #
--echo # In MariaDB, we do:
delimiter |;
create procedure save_read_stats() create procedure save_read_stats()
select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT begin
into @rr, @rq, @rif, @rin set @rr=(select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database());
set @rif= (select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first');
set @rin=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next');
set @icp_attempts=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts');
set @icp_matches=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match');
end|
create procedure get_read_stats() create procedure get_read_stats()
begin
select select
ROWS_READ-@rr, ROWS_REQUESTED-@rq, ROWS_INDEX_FIRST-@rif, ROWS_INDEX_NEXT-@rin (select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database()
) - @rr as ROWS_READ_DIFF,
(select VARIABLE_VALUE - @rif
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
(select VARIABLE_VALUE - @rin
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
(select VARIABLE_VALUE - @icp_attempts
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
(select VARIABLE_VALUE - @icp_matches
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
end|
delimiter ;|
eval eval
create table t4 ( create table t4 (
......
...@@ -50,23 +50,17 @@ EXPLAIN ...@@ -50,23 +50,17 @@ EXPLAIN
"table": { "table": {
"table_name": "t3", "table_name": "t3",
"access_type": "range", "access_type": "range",
"possible_keys": [ "possible_keys": ["kp1"],
"kp1"
],
"key": "kp1", "key": "kp1",
"used_key_parts": [
"kp1"
],
"key_length": "5", "key_length": "5",
"used_key_parts": ["kp1"],
"rows": 1000, "rows": 1000,
"filtered": 100, "filtered": 100,
"index_condition": "((`test`.`t3`.`kp1` between 2 and 4) and ((`test`.`t3`.`kp1` % 3) = 0))", "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 % 3 = 0",
"attached_condition": "(`test`.`t3`.`kp2` like '%foo%')" "attached_condition": "t3.kp2 like '%foo%'"
} }
} }
} }
Warnings:
Note 1003 /* select#1 */ select `test`.`t3`.`pk` AS `pk`,`test`.`t3`.`kp1` AS `kp1`,`test`.`t3`.`kp2` AS `kp2`,`test`.`t3`.`col1` AS `col1` from `test`.`t3` where ((`test`.`t3`.`kp1` between 2 and 4) and ((`test`.`t3`.`kp1` % 3) = 0) and (`test`.`t3`.`kp2` like '%foo%'))
# Check that we handle the case where out-of-range is encountered sooner # Check that we handle the case where out-of-range is encountered sooner
# than matched index condition # than matched index condition
explain explain
...@@ -82,10 +76,11 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -82,10 +76,11 @@ id select_type table type possible_keys key key_len ref rows Extra
select * from t2 where kp1< 3 and kp2+1>50000; select * from t2 where kp1< 3 and kp2+1>50000;
pk kp1 kp2 col1 pk kp1 kp2 col1
# Try doing backwards scans # Try doing backwards scans
# MariaDB: ICP is not supported for reverse scans.
explain explain
select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
10 10 10 10 10 10 10 10
...@@ -96,7 +91,7 @@ pk kp1 kp2 col1 ...@@ -96,7 +91,7 @@ pk kp1 kp2 col1
explain explain
select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
998 998 998 998 998 998 998 998
...@@ -106,7 +101,7 @@ pk kp1 kp2 col1 ...@@ -106,7 +101,7 @@ pk kp1 kp2 col1
explain explain
select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc; select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc; select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
drop table t0,t1,t2,t3; drop table t0,t1,t2,t3;
...@@ -115,16 +110,48 @@ drop table t0,t1,t2,t3; ...@@ -115,16 +110,48 @@ drop table t0,t1,t2,t3;
# #
# First, some preparations # First, some preparations
# #
# in facebook/mysql-5.6, it was:
# select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
#
# In MariaDB, we do:
create procedure save_read_stats() create procedure save_read_stats()
select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT begin
into @rr, @rq, @rif, @rin set @rr=(select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database());
set @rif= (select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first');
set @rin=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next');
set @icp_attempts=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts');
set @icp_matches=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match');
end|
create procedure get_read_stats() create procedure get_read_stats()
begin
select select
ROWS_READ-@rr, ROWS_REQUESTED-@rq, ROWS_INDEX_FIRST-@rif, ROWS_INDEX_NEXT-@rin (select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database()
) - @rr as ROWS_READ_DIFF,
(select VARIABLE_VALUE - @rif
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
(select VARIABLE_VALUE - @rin
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
(select VARIABLE_VALUE - @icp_attempts
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
(select VARIABLE_VALUE - @icp_matches
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
end|
create table t4 ( create table t4 (
id int, id int,
id1 int, id1 int,
...@@ -142,8 +169,8 @@ insert into t4 values ...@@ -142,8 +169,8 @@ insert into t4 values
# #
call save_read_stats(); call save_read_stats();
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr ROWS_REQUESTED-@rq ROWS_INDEX_FIRST-@rif ROWS_INDEX_NEXT-@rin ROWS_READ_DIFF ROWS_INDEX_FIRST ROWS_INDEX_NEXT ICP_ATTEMPTS ICP_MATCHES
0 0 0 0 0 0 0 0 0
# ============== index-only query ============== # ============== index-only query ==============
explain explain
select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
...@@ -154,10 +181,11 @@ select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -154,10 +181,11 @@ select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id1 id2 id1 id2
1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 10 ROWS_READ_DIFF 10
ROWS_REQUESTED-@rq 11 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 10
ROWS_INDEX_NEXT-@rin 9 ICP_ATTEMPTS 0
ICP_MATCHES 0
# ============== Query without ICP ============== # ============== Query without ICP ==============
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
explain explain
...@@ -169,10 +197,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -169,10 +197,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id id1 id2 value value2 id id1 id2 value value2
1 1 1 1 1 1 1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 10 ROWS_READ_DIFF 10
ROWS_REQUESTED-@rq 11 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 10
ROWS_INDEX_NEXT-@rin 9 ICP_ATTEMPTS 0
ICP_MATCHES 0
# ============== Query with ICP ============== # ============== Query with ICP ==============
set optimizer_switch='index_condition_pushdown=on'; set optimizer_switch='index_condition_pushdown=on';
explain explain
...@@ -184,10 +213,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -184,10 +213,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id id1 id2 value value2 id id1 id2 value value2
1 1 1 1 1 1 1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 1 ROWS_READ_DIFF 1
ROWS_REQUESTED-@rq 1 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 1
ROWS_INDEX_NEXT-@rin 0 ICP_ATTEMPTS 10
ICP_MATCHES 1
drop table t4; drop table t4;
drop procedure save_read_stats; drop procedure save_read_stats;
drop procedure get_read_stats; drop procedure get_read_stats;
...@@ -212,7 +242,7 @@ set @count=0; ...@@ -212,7 +242,7 @@ set @count=0;
explain explain
select * from t1 where key1=1; select * from t1 where key1=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 t1 ref key1 key1 9 const # Using index condition 1 SIMPLE t1 ref key1 key1 9 const #
set @count_diff =(select (value - @count) from information_schema.rocksdb_perf_context 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'); where table_schema=database() and table_name='t1' and stat_type='INTERNAL_KEY_SKIPPED_COUNT');
select * from t1 where key1=1; select * from t1 where key1=1;
......
...@@ -50,23 +50,17 @@ EXPLAIN ...@@ -50,23 +50,17 @@ EXPLAIN
"table": { "table": {
"table_name": "t3", "table_name": "t3",
"access_type": "range", "access_type": "range",
"possible_keys": [ "possible_keys": ["kp1"],
"kp1"
],
"key": "kp1", "key": "kp1",
"used_key_parts": [
"kp1"
],
"key_length": "5", "key_length": "5",
"used_key_parts": ["kp1"],
"rows": 1000, "rows": 1000,
"filtered": 100, "filtered": 100,
"index_condition": "((`test`.`t3`.`kp1` between 2 and 4) and ((`test`.`t3`.`kp1` % 3) = 0))", "index_condition": "t3.kp1 between 2 and 4 and t3.kp1 % 3 = 0",
"attached_condition": "(`test`.`t3`.`kp2` like '%foo%')" "attached_condition": "t3.kp2 like '%foo%'"
} }
} }
} }
Warnings:
Note 1003 /* select#1 */ select `test`.`t3`.`pk` AS `pk`,`test`.`t3`.`kp1` AS `kp1`,`test`.`t3`.`kp2` AS `kp2`,`test`.`t3`.`col1` AS `col1` from `test`.`t3` where ((`test`.`t3`.`kp1` between 2 and 4) and ((`test`.`t3`.`kp1` % 3) = 0) and (`test`.`t3`.`kp2` like '%foo%'))
# Check that we handle the case where out-of-range is encountered sooner # Check that we handle the case where out-of-range is encountered sooner
# than matched index condition # than matched index condition
explain explain
...@@ -82,10 +76,11 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -82,10 +76,11 @@ id select_type table type possible_keys key key_len ref rows Extra
select * from t2 where kp1< 3 and kp2+1>50000; select * from t2 where kp1< 3 and kp2+1>50000;
pk kp1 kp2 col1 pk kp1 kp2 col1
# Try doing backwards scans # Try doing backwards scans
# MariaDB: ICP is not supported for reverse scans.
explain explain
select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 between 1 and 10 and mod(kp2,2)=0 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
10 10 10 10 10 10 10 10
...@@ -96,7 +91,7 @@ pk kp1 kp2 col1 ...@@ -96,7 +91,7 @@ pk kp1 kp2 col1
explain explain
select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc; select * from t2 where kp1 >990 and mod(kp2,2)=0 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
998 998 998 998 998 998 998 998
...@@ -106,7 +101,7 @@ pk kp1 kp2 col1 ...@@ -106,7 +101,7 @@ pk kp1 kp2 col1
explain explain
select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc; select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
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 t2 range kp1 kp1 5 NULL # Using index condition 1 SIMPLE t2 range kp1 kp1 5 NULL # Using where
select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc; select * from t2 where kp1< 3 and kp2+1>50000 order by kp1 desc;
pk kp1 kp2 col1 pk kp1 kp2 col1
drop table t0,t1,t2,t3; drop table t0,t1,t2,t3;
...@@ -115,16 +110,48 @@ drop table t0,t1,t2,t3; ...@@ -115,16 +110,48 @@ drop table t0,t1,t2,t3;
# #
# First, some preparations # First, some preparations
# #
# in facebook/mysql-5.6, it was:
# select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT
#
# In MariaDB, we do:
create procedure save_read_stats() create procedure save_read_stats()
select ROWS_READ, ROWS_REQUESTED, ROWS_INDEX_FIRST, ROWS_INDEX_NEXT begin
into @rr, @rq, @rif, @rin set @rr=(select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database());
set @rif= (select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first');
set @rin=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next');
set @icp_attempts=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts');
set @icp_matches=(select VARIABLE_VALUE
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match');
end|
create procedure get_read_stats() create procedure get_read_stats()
begin
select select
ROWS_READ-@rr, ROWS_REQUESTED-@rq, ROWS_INDEX_FIRST-@rif, ROWS_INDEX_NEXT-@rin (select ROWS_READ
from information_schema.table_statistics from information_schema.table_statistics
where table_name='t4' and table_schema=database(); where table_name='t4' and table_schema=database()
) - @rr as ROWS_READ_DIFF,
(select VARIABLE_VALUE - @rif
from information_schema.session_status
where VARIABLE_NAME='Handler_read_first') as ROWS_INDEX_FIRST,
(select VARIABLE_VALUE - @rin
from information_schema.session_status
where VARIABLE_NAME='Handler_read_next') as ROWS_INDEX_NEXT,
(select VARIABLE_VALUE - @icp_attempts
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_attempts') as ICP_ATTEMPTS,
(select VARIABLE_VALUE - @icp_matches
from information_schema.session_status
where VARIABLE_NAME='Handler_icp_match') as ICP_MATCHES;
end|
create table t4 ( create table t4 (
id int, id int,
id1 int, id1 int,
...@@ -142,8 +169,8 @@ insert into t4 values ...@@ -142,8 +169,8 @@ insert into t4 values
# #
call save_read_stats(); call save_read_stats();
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr ROWS_REQUESTED-@rq ROWS_INDEX_FIRST-@rif ROWS_INDEX_NEXT-@rin ROWS_READ_DIFF ROWS_INDEX_FIRST ROWS_INDEX_NEXT ICP_ATTEMPTS ICP_MATCHES
0 0 0 0 0 0 0 0 0
# ============== index-only query ============== # ============== index-only query ==============
explain explain
select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
...@@ -154,10 +181,11 @@ select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -154,10 +181,11 @@ select id1,id2 from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id1 id2 id1 id2
1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 10 ROWS_READ_DIFF 10
ROWS_REQUESTED-@rq 11 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 10
ROWS_INDEX_NEXT-@rin 9 ICP_ATTEMPTS 0
ICP_MATCHES 0
# ============== Query without ICP ============== # ============== Query without ICP ==============
set optimizer_switch='index_condition_pushdown=off'; set optimizer_switch='index_condition_pushdown=off';
explain explain
...@@ -169,10 +197,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -169,10 +197,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id id1 id2 value value2 id id1 id2 value value2
1 1 1 1 1 1 1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 10 ROWS_READ_DIFF 10
ROWS_REQUESTED-@rq 11 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 10
ROWS_INDEX_NEXT-@rin 9 ICP_ATTEMPTS 0
ICP_MATCHES 0
# ============== Query with ICP ============== # ============== Query with ICP ==============
set optimizer_switch='index_condition_pushdown=on'; set optimizer_switch='index_condition_pushdown=on';
explain explain
...@@ -184,10 +213,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1; ...@@ -184,10 +213,11 @@ select * from t4 force index (id1_id2) where id1=1 and id2 % 10 = 1;
id id1 id2 value value2 id id1 id2 value value2
1 1 1 1 1 1 1 1 1 1
call get_read_stats(); call get_read_stats();
ROWS_READ-@rr 1 ROWS_READ_DIFF 1
ROWS_REQUESTED-@rq 1 ROWS_INDEX_FIRST 0
ROWS_INDEX_FIRST-@rif 1 ROWS_INDEX_NEXT 1
ROWS_INDEX_NEXT-@rin 0 ICP_ATTEMPTS 10
ICP_MATCHES 1
drop table t4; drop table t4;
drop procedure save_read_stats; drop procedure save_read_stats;
drop procedure get_read_stats; drop procedure get_read_stats;
--rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --rocksdb_perf_context_level=2 --rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --rocksdb_perf_context_level=2 --userstat=ON
--rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --rocksdb_debug_optimizer_n_rows=20000 --rocksdb_records_in_range=1000 --userstat=ON
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