MyRocks and Bloom Filters

You are viewing an old version of this article. View the current version here.

Bloom filters are used to reduce read amplification. Bloom filter can be set on a per-column family basis ( see myrocks-column-families).

Bloom filter parameters

  • How many bits to use
  • whole_key_filtering=true/false (TODO what is that?)
  • Whether the bloom filter is for the entire key or for the prefix. In case of a prefix, you need to look at the index definition and compute the desired prefix length.

Computing prefix length

  • It's 4 bytes for index_nr
  • Then it is key_length as shown by EXPLAIN.

Enabling bloom filter:

To enable 10-bit bloom filter for 4-byte prefix length for column family "cf1", put this into my.cnf:

rocksdb_override_cf_options='cf1={block_based_table_factory={filter_policy=bloomfilter:10:false;whole_key_filtering=0;};prefix_extractor=capped:4};'

and restart the server.

Check if the column family actually uses the bloom filter:

<<code:sql>>
select * 
from information_schema.rocksdb_cf_options 
where 
  cf_name='cf1' and
  option_type IN ('TABLE_FACTORY::FILTER_POLICY','PREFIX_EXTRACTOR');
<</code>>

<code>> +---------+------------------------------+----------------------------+

CF_NAMEOPTION_TYPEVALUE

+---------+------------------------------+----------------------------+

cf1PREFIX_EXTRACTORrocksdb.CappedPrefix.4
cf1TABLE_FACTORY::FILTER_POLICYrocksdb.BuiltinBloomFilter

+---------+------------------------------+----------------------------+ <</code>>

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.