CREATE INDEX builds a secondary index on one or more table columns to speed up point lookup and range queries in BigQuery.
Indexes let BigQuery skip full table scans for highly selective filters, reducing scan costs and latency on large tables.
BigQuery currently supports SEARCH indexes for equality, range, and phrase matching on STRING, INT64, NUMERIC, and TIMESTAMP columns.
Use CREATE SEARCH INDEX
followed by the index name, target table, and column list.Add IF NOT EXISTS
to avoid errors if the index already exists.
List multiple columns inside the parentheses in the order you want them indexed. BigQuery optimizes queries that match the leading columns of the index.
Yes. Use the OPTIONS
clause to set properties such as field_length
or include_null_keys
.
Indexes consume extra storage—roughly 20–30% of the indexed data size.Query costs may drop, but storage costs increase.
Use DROP SEARCH INDEX index_name
to remove it. Re-create to rebuild. BigQuery handles locking transparently.
Create indexes only on columns used frequently in selective predicates. Avoid indexing high-cardinality JSON fields until needed.Monitor EXPLAIN
plans to confirm index usage.
The query section below shows how an index on Orders.customer_id
accelerates lookups of a single customer’s orders.
Run EXPLAIN
or check the "query_plan" in the job statistics. A stage labelled SEARCH_INDEX_SCAN indicates index use.
.
Yes. Inserts, updates, and deletes propagate to the index synchronously, so no manual maintenance is required.
Currently, SEARCH indexes support simple and array columns but not nested STRUCT fields. Flatten nested data into top-level columns first.
Creation time depends on table size. Expect roughly one minute per 10 GB of data, but BigQuery builds the index in the background without blocking reads and writes.