Skip to content

Commit

Permalink
Issue facebook#33: SELECT ... FROM rocksdb_table ORDER BY primary_key…
Browse files Browse the repository at this point in the history
… uses sorting

Summary:
Fix the index properties returned by the storage engine:
- ha_rocksdb::primary_key_is_clustered()= true;
- ha_rocksdb::keys_to_use_for_scanning()= &key_map_full;

Test Plan: mtr

Reviewers: maykov, jonahcohen, hermanlee4, yoshinorim

Reviewed By: yoshinorim

Subscribers: jtolmer

Differential Revision: https://reviews.facebook.net/D33957
  • Loading branch information
spetrunia authored and jkedgar committed Jan 4, 2017
1 parent f16c398 commit cc760b8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mysql-test/r/rocksdb.result
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ rocksdb_max_row_locks 1073741824
rocksdb_max_total_wal_size 0
rocksdb_no_block_cache OFF
rocksdb_paranoid_checks ON
rocksdb_perf_context_level 1
rocksdb_rate_limiter_bytes_per_sec 0
rocksdb_skip_log_error_on_recovery OFF
rocksdb_stats_dump_period_sec 3600
Expand Down Expand Up @@ -1666,3 +1667,13 @@ select if((@var2 - @var1) < 30, 1, @var2-@var1);
if((@var2 - @var1) < 30, 1, @var2-@var1)
1
drop table t0,t1;
#
# Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting
#
create table t1 (id int primary key, value int) engine=rocksdb;
insert into t1 values (1,1),(2,2),(3,3);
# The following must not use 'Using filesort':
explain select * from t1 ORDER BY id;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 Using filesort
drop table t1;
11 changes: 11 additions & 0 deletions mysql-test/t/rocksdb.test
Original file line number Diff line number Diff line change
Expand Up @@ -1317,3 +1317,14 @@ set @var2=(select variable_value
select if((@var2 - @var1) < 30, 1, @var2-@var1);

drop table t0,t1;

--echo #
--echo # Issue #33: SELECT ... FROM rocksdb_table ORDER BY primary_key uses sorting
--echo #
create table t1 (id int primary key, value int) engine=rocksdb;
insert into t1 values (1,1),(2,2),(3,3);
--echo # The following must not use 'Using filesort':
explain select * from t1 ORDER BY id;

drop table t1;

9 changes: 9 additions & 0 deletions storage/rocksdb/ha_rocksdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@ class ha_rocksdb: public handler
*/
ulong index_flags(uint inx, uint part, bool all_parts) const;

const key_map * keys_to_use_for_scanning()
{
return &key_map_full;
}
bool primary_key_is_clustered()
{
return true;
}

int rename_table(const char *from, const char *to);

int convert_record_from_storage_format(rocksdb::Slice *slice, uchar *buf);
Expand Down

0 comments on commit cc760b8

Please sign in to comment.