v.21.11New Features
Support for String Key Maps in TokenBF with Enhanced Data Skipping in Queries
tokenbf_v1andngramsupport Map with key of String of FixedSring type. It enhance data skipping in query with map key filter.sql CREATE TABLE map_tokenbf ( row_id UInt32, map Map(String, String), INDEX map_tokenbf map TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1 ) Engine=MergeTree() Order by idWith table above, the queryselect * from map_tokebf where map['K']='V'will skip the granule that doesn't contain keyA. Of course, how many rows will skipped is depended on thegranularityandindex_granularityyou set. #28511 (凌涛).
Why it matters
This feature improves query performance by enabling more efficient granule skipping when filtering on Map keys of String or FixedString types. It allows indexes on map keys to reduce the amount of data scanned during query execution, thereby speeding up lookups and saving resources.How to use it
Define a Map column with String or FixedString keys and create an index on it usingngrambf_v1 or tokenbf_v1 index types with appropriate granularity. For example:CREATE TABLE map_tokenbf (
row_id UInt32,
map Map(String, String),
INDEX map_tokenbf_map TYPE ngrambf_v1(4,256,2,0) GRANULARITY 1
) ENGINE=MergeTree()
ORDER BY row_idThen queries filtering by map keys like
map['K'] = 'V' will benefit from skipping granules without the specified key/value.