Skip to main content

Syntax

Indexes can be standard for accelerating lookups and sorts or vector indexes for similarity search in machine learning, AI applications, etc.
Standard index syntax
Vector index syntax
Vector index is added in v2.6.0 and is in technical preview stage. Currently, we only support creating vector indexes on append-only inputs, such as append-only tables or materialized views.

Parameters

Backfill and isolation

When creating an index, RisingWave will backfill historical data from the indexed table or materialized view. Snapshot backfill is enabled by default to improve isolation between the backfill phase and streaming phase. This helps prevent resource contention between backfilling historical data and processing new streaming data. To disable it if needed, set SET streaming_use_snapshot_backfill=false; before creating the index. For more details, see View and configure runtime parameters. In RisingWave Cloud, you can offload index backfill to dedicated serverless backfiller nodes. Enable it for the current session with SET enable_serverless_backfill = true; or for one statement with WITH (cloud.serverless_backfill_enabled = true). For setup and limitations, see Serverless backfilling.

Examples

Standard index

Let’s create two tables, customers and orders.
If you want to speed up the query of fetching a customer record by the phone number, you can build an index on the c_phone column in the customers table.
If you want to speed up the query of fetching all the orders of a customer by the customer key, you can build an index on the o_custkey column in the orders table.

Vector index

In an e-commerce platform, each product can be represented by an embedding vector that captures semantic features derived from its title and description. A vector index can then be used to recommend items similar to a user’s query.
  1. Create a table with vector data. This stores product information along with a semantic embedding vector that represents its features.
  1. Build a vector index to enable fast similarity search. Include product attributes (name, description) in the index for direct retrieval.
  1. Given a query vector (e.g., representing “blue running shoes”), retrieve the top 5 most similar products.