How it works
For example, you create a bloom filter index on acolumn1 of a given table table1 and run a query such as Select xxx from table1 where column1 = something;. Then the following situations happen when the database scans the data files of table1.
- If the bloom filter index detects that a data page does not contain the data to be filtered, the database skips the data page to improve query performance.
- If the bloom filter index detects that a data page may contain the data to be filtered, the database reads the data page to check whether the data exists. Note that the bloom filter can tell you for sure if a value is not present, but it cannot say for sure that a value is present, only that it may be present. Using a bloom filter index to determine whether a value is present may give false positives, which means that a bloom filter index detects that a data page contains the data to be filtered, but the data page does not actually contain the data.
Usage notes
- You can create bloom filter indexes for all columns of a Duplicate Key or Primary Key table. For an Aggregate table or Unique Key table, you can only create bloom filter indexes for key columns.
- Bloom filter indexes can be created for columns of the following data types:
- Numeric types: SMALLINT, INT, BIGINT, and LARGEINT.
- String types: CHAR, STRING, and VARCHAR.
- Date types: DATE and DATETIME.
- Bloom filter indexes can only improve the performance of queries that contain the
in,=, andIS NULLoperators, such asSelect xxx from table where x in {},Select xxx from table where column = xxx, andSelect xxx from table where column IS NULL. - You can check whether a query uses bloom filter indexes by viewing the
BloomFilterFilterRowsfield of the query’s profile.
Create bloom filter indexes
You can create a bloom filter index for a column when you create a table by specifying thebloom_filter_columns parameter in PROPERTIES. For example, create bloom filter indexes for the k1 and k2 columns in table1.
,). For other parameter descriptions of the CREATE TABLE statement, see CREATE TABLE.
Display bloom filter indexes
For example, the following statement displays bloom filter indexes oftable1. For the output description, see SHOW CREATE TABLE.
Modify bloom filter indexes
You can add, reduce, and delete bloom filter indexes by using the ALTER TABLE statement.-
The following statement adds a bloom filter index on the
v1column. -
The following statement reduces the bloom filter index on the
k2column. -
The following statement deletes all bloom filter indexes of
table1.
Note: Altering an index is an asynchronous operation. You can view the progress of this operation by executing SHOW ALTER TABLE. You can run only one alter index task on a table each time.