|
| 1 | +CREATE TABLE `linktable` ( |
| 2 | +`id1` bigint(20) unsigned NOT NULL DEFAULT '0', |
| 3 | +`id1_type` int(10) unsigned NOT NULL DEFAULT '0', |
| 4 | +`id2` bigint(20) unsigned NOT NULL DEFAULT '0', |
| 5 | +`id2_type` int(10) unsigned NOT NULL DEFAULT '0', |
| 6 | +`link_type` bigint(20) unsigned NOT NULL DEFAULT '0', |
| 7 | +`visibility` tinyint(3) NOT NULL DEFAULT '0', |
| 8 | +`data` varchar(255) NOT NULL DEFAULT '', |
| 9 | +`time` bigint(20) unsigned NOT NULL DEFAULT '0', |
| 10 | +`version` int(11) unsigned NOT NULL DEFAULT '0', |
| 11 | +PRIMARY KEY (link_type, `id1`,`id2`) COMMENT 'cf_link_pk', |
| 12 | +KEY `id1_type` (`id1`,`link_type`,`visibility`,`time`,`version`,`data`) COMMENT 'rev:cf_link_id1_type', |
| 13 | +KEY `id1_type2` (`id1`,`link_type`,`time`,`version`,`data`,`visibility`) COMMENT 'rev:cf_link_id1_type2', |
| 14 | +KEY `id1_type3` (`id1`,`visibility`,`time`,`version`,`data`,`link_type`) COMMENT 'rev:cf_link_id1_type3' |
| 15 | +) ENGINE=RocksDB DEFAULT COLLATE=latin1_bin; |
| 16 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 17 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc; |
| 18 | +id1 id2 link_type visibility data time version |
| 19 | +100 100 1 1 100 100 100 |
| 20 | +select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 21 | +case when variable_value-@c > 0 then 'true' else 'false' end |
| 22 | +true |
| 23 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 24 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc; |
| 25 | +id1 id2 link_type visibility data time version |
| 26 | +100 100 1 1 100 100 100 |
| 27 | +select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 28 | +case when variable_value-@c > 0 then 'true' else 'false' end |
| 29 | +true |
| 30 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 31 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc; |
| 32 | +id1 id2 link_type visibility data time version |
| 33 | +100 100 1 1 100 100 100 |
| 34 | +select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 35 | +case when variable_value-@c = 0 then 'true' else 'false' end |
| 36 | +true |
| 37 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 38 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 and time >= 0 order by time desc; |
| 39 | +id1 id2 link_type visibility data time version |
| 40 | +100 100 1 1 100 100 100 |
| 41 | +select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 42 | +case when variable_value-@c > 0 then 'true' else 'false' end |
| 43 | +true |
| 44 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 45 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 order by time desc; |
| 46 | +id1 id2 link_type visibility data time version |
| 47 | +100 100 1 1 100 100 100 |
| 48 | +select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 49 | +case when variable_value-@c = 0 then 'true' else 'false' end |
| 50 | +true |
| 51 | +## HA_READ_PREFIX_LAST |
| 52 | +# BF len 20 |
| 53 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 54 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 order by time desc; |
| 55 | +id1 id2 link_type visibility data time version |
| 56 | +100 100 1 1 100 100 100 |
| 57 | +select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 58 | +case when variable_value-@c > 0 then 'true' else 'false' end |
| 59 | +true |
| 60 | +# BF len 19 |
| 61 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 62 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 order by time desc; |
| 63 | +id1 id2 link_type visibility data time version |
| 64 | +100 100 1 1 100 100 100 |
| 65 | +select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 66 | +case when variable_value-@c = 0 then 'true' else 'false' end |
| 67 | +true |
| 68 | +# BF len 12 |
| 69 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 70 | +select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and visibility = 1 order by time desc; |
| 71 | +id1 id2 link_type visibility data time version |
| 72 | +100 100 1 1 100 100 100 |
| 73 | +select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 74 | +case when variable_value-@c = 0 then 'true' else 'false' end |
| 75 | +true |
| 76 | +DROP TABLE linktable; |
| 77 | +# |
| 78 | +# bloom filter prefix is 20 byte |
| 79 | +# Create a key which is longer than that, so that we see that |
| 80 | +# eq_cond_len= slice.size() - 1; |
| 81 | +# doesnt work. |
| 82 | +# |
| 83 | +# indexnr 4 |
| 84 | +# kp0 + 4 = 8 |
| 85 | +# kp1 + 8 = 16 |
| 86 | +# kp2 + 8 = 24 24>20 byte length prefix |
| 87 | +# kp3 + 8 = 28 |
| 88 | +create table t1 ( |
| 89 | +pk int primary key, |
| 90 | +kp0 int not null, |
| 91 | +kp1 bigint not null, |
| 92 | +kp2 bigint not null, |
| 93 | +kp3 bigint not null, |
| 94 | +key kp12(kp0, kp1, kp2, kp3) comment 'rev:x1' |
| 95 | +) engine=rocksdb; |
| 96 | +insert into t1 values (1, 1,1, 1,1); |
| 97 | +insert into t1 values (10,1,1,0x12FFFFFFFFFF,1); |
| 98 | +insert into t1 values (11,1,1,0x12FFFFFFFFFF,1); |
| 99 | +insert into t1 values (20,2,2,0x12FFFFFFFFFF,1); |
| 100 | +insert into t1 values (21,2,2,0x12FFFFFFFFFF,1); |
| 101 | +explain |
| 102 | +select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc; |
| 103 | +id select_type table type possible_keys key key_len ref rows Extra |
| 104 | +1 SIMPLE t1 ref kp12 kp12 20 const,const,const 1 Using where; Using index |
| 105 | +show status like '%rocksdb_bloom_filter_prefix%'; |
| 106 | +Variable_name Value |
| 107 | +rocksdb_bloom_filter_prefix_checked 0 |
| 108 | +rocksdb_bloom_filter_prefix_useful 0 |
| 109 | +select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 110 | +select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc; |
| 111 | +pk kp0 kp1 kp2 kp3 |
| 112 | +11 1 1 20890720927743 1 |
| 113 | +10 1 1 20890720927743 1 |
| 114 | +show status like '%rocksdb_bloom_filter_prefix%'; |
| 115 | +Variable_name Value |
| 116 | +rocksdb_bloom_filter_prefix_checked 0 |
| 117 | +rocksdb_bloom_filter_prefix_useful 0 |
| 118 | +# The following MUST show TRUE: |
| 119 | +select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; |
| 120 | +case when variable_value-@c = 0 then 'true' else 'false' end |
| 121 | +true |
| 122 | +drop table t1; |
0 commit comments