summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test
blob: 161f7b566f50f537819b87599c9bf47336e34b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--source include/have_rocksdb.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

CREATE TABLE t1 (id1 BIGINT, id2 BIGINT, id3 BIGINT, id4 BIGINT, PRIMARY KEY (id1, id2, id3, id4) comment 'cf1') ENGINE=rocksdb collate latin1_bin;
--disable_query_log
let $i = 1;
while ($i <= 100) {
  let $insert = INSERT INTO t1 VALUES(1, $i, $i, $i);
  eval $insert;
  inc $i;
}
--enable_query_log
set global rocksdb_force_flush_memtable_now = 1;

--echo
--echo Original Prefix Extractor:
--echo
--sorted_result
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';

# BF used (4+8+8+8)
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';

--let $_mysqld_option=--rocksdb_override_cf_options=cf1={prefix_extractor=capped:26};

--echo
--echo Prefix Extractor (after override_cf_options set, should not be changed):
--echo
--sorted_result
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';

SET @@global.rocksdb_update_cf_options = 'cf1={prefix_extractor=capped:26};';
--echo
--echo Changed Prefix Extractor (after update_cf_options set, without restart):
--echo
--sorted_result
# Restart no longer needed
SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%';

# Satisfies can_use_bloom_filter (4+8+8+8), but can't use because the old SST
# files have old prefix extractor
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';

# Insert more data into t1, verify it uses new bloom filter
--disable_query_log
let $i = 101;
while ($i <= 200) {
  let $insert = INSERT INTO t1 VALUES(1, $i, $i, $i);
  eval $insert;
  inc $i;
}
--enable_query_log

set global rocksdb_force_flush_memtable_now = 1;

# BF used w/ new prefix extractor (4+8+8+8) (still increments once because it
# needs to check the new SST file, but doesnt increment for SST file with old
# extractor)
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';

# should have 2 sst files, one with old prefix extractor and one with new
SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;

# update some old data, force compaction, verify that new SST files use
# new bloom filter
UPDATE t1 SET id1=1,id2 = 30,id3 = 30 WHERE id4 >= 0 AND id4 <=10;
set global rocksdb_force_flush_memtable_now = 1;

# should have 3 sst files, one with old prefix extractor and two with new
SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1;
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1;
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';

SET @@global.rocksdb_update_cf_options = '';
set global rocksdb_compact_cf='cf1';

# Select the updated, make sure bloom filter is checked now
select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';
SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=30 AND id3=30;
select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked';

DROP TABLE t1;