INDEX

Warning

Supported only for row-oriented tables. Support for column-oriented tables is currently under development.

The INDEX construct is used to define a secondary index in a row-oriented table:

CREATE TABLE table_name (
    ...
    INDEX <index_name> GLOBAL [SYNC|ASYNC] ON ( <index_columns> ) COVER ( <cover_columns> ),
    ...
)

Where:

  • Index_name is the unique name of the index to be used to access data.
  • SYNC/ASYNC indicates synchronous/asynchronous data writes to the index. If not specified, synchronous.
  • Index_columns is a list of comma-separated names of columns in the created table to be used for a search in the index.
  • Cover_columns is a list of comma-separated names of columns in the created table, which will be stored in the index in addition to the search columns, making it possible to fetch additional data without accessing the table for it.

Example

CREATE TABLE my_table (
    a Uint64,
    b Bool,
    c Utf8,
    d Date,
    INDEX idx_d GLOBAL ON (d),
    INDEX idx_ba GLOBAL ASYNC ON (b, a) COVER (c),
    PRIMARY KEY (a)
)
Previous
Next