forked from percona/percona-server
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make MyRocks range scan cost calculation more accurate (percona#212)
Summary: MyRocks had two bugs when calculating index scan cost. 1. block_size was not considered. This made covering index scan cost (both full index scan and range scan) much higher 2. ha_rocksdb::records_in_range() may have estimated more rows than the estimated number of rows in the table. This was wrong, and MySQL optimizer decided to use full index scan even though range scan was more efficient. This diff fixes percona#1 by setting stats.block_size at ha_rocksdb::open(), and fixes percona#2 by reducing the number of estimated rows if it was larger than stats.records. Test Plan: mtr, updating some affected test cases, and new test case rocksdb_range2 Reviewers: hermanlee4, jkedgar, spetrunia Reviewed By: spetrunia Subscribers: MarkCallaghan, webscalesql-eng Differential Revision: https://reviews.facebook.net/D55869
- Loading branch information
1 parent
bedf7b4
commit 80d27a2
Showing
5 changed files
with
44 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2)); | ||
analyze table t1; | ||
Table Op Msg_type Msg_text | ||
test.t1 analyze status OK | ||
select count(*) from t1; | ||
count(*) | ||
10000 | ||
explain select c1 from t1 where c1 > 5 limit 10; | ||
id select_type table type possible_keys key key_len ref rows Extra | ||
1 SIMPLE t1 range i i 9 NULL 9900 Using where; Using index | ||
drop table t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--source include/have_rocksdb.inc | ||
|
||
# Issue#212 MyRocks chooses full index scan even if range scan is more efficient | ||
# rocksdb_debug_optimizer_n_rows must not be set. | ||
|
||
create table t1 (id1 bigint, id2 bigint, c1 bigint, c2 bigint, c3 bigint, c4 bigint, c5 bigint, c6 bigint, c7 bigint, primary key (id1, id2), index i(c1, c2)); | ||
--disable_query_log | ||
let $i=0; | ||
while ($i<10000) | ||
{ | ||
inc $i; | ||
eval insert t1(id1, id2, c1, c2, c3, c4, c5, c6, c7) | ||
values($i, 0, $i, 0, 0, 0, 0, 0, 0); | ||
} | ||
--enable_query_log | ||
analyze table t1; | ||
select count(*) from t1; | ||
explain select c1 from t1 where c1 > 5 limit 10; | ||
drop table t1; | ||
|