Back to Yugabyte Db

Indexes and constraints in YugabyteDB YCQL

docs/content/v2024.2/explore/ycql-language/indexes-constraints/_index.md

2026.1.0.0-b292.9 KB
Original Source

As with tables, indexes in YugabyteDB are stored in a distributed manner - that is, they are split into tablets and replicated. Updates to indexes are transactional, which means that row updates and the corresponding index updates occur as a single transaction. Similar to tables, they are stored in LSM format.

{{<note>}} The sharding of indexes is based on the primary key of the index and is independent of how the main table is sharded/distributed. Indexes are not colocated with the base table. {{</note>}}

The YCQL API supports most of the Cassandra index semantics while incorporating other improvements.

The following table lists different types of indexes and their support in YCQL.

TypeDescription
{{<icon/yes>}}Primary keyUnique key that identifies the row
{{<icon/no>}}Foreign keyLink to a column in another table
{{<icon/yes>}}Secondary indexIndex on columns other than the primary key
{{<icon/yes>}}Unique indexSet one or many columns to be unique
{{<icon/yes>}}Multi-column indexIndex on multiple columns for faster scan with lesser rows
{{<icon/yes>}}Partial indexIndexes that apply to only some rows of the table
{{<icon/yes>}}Covering indexStore other columns in the index for faster retrieval
{{<icon/no>}}Expression indexIndex based on a functional operation on columns
{{<icon/no>}}GIN indexGeneralized inverted index for fast text search
{{<icon/no>}}GIST IndexFor spatial search. Tracked - {{<issue 1337>}}

Learn more

{{<index/block>}}

{{<index/item title="Primary keys" body="Explore the use of primary keys in YCQL." href="primary-key-ycql/" icon="fa-thin fa-bars">}}

{{<index/item title="Secondary and multi-column indexes" body="Explore indexes to optimize your database performance with examples." href="secondary-indexes-ycql/" icon="fa-thin fa-list-ol">}}

{{<index/item title="Unique indexes" body="Explore unique indexes in YCQL with examples." href="unique-index-ycql/" icon="fa-thin fa-bars-staggered">}}

{{<index/item title="Partial indexes" body="Explore partial indexes in YCQL with examples." href="partial-index-ycql/" icon="fa-thin fa-list-check">}}

{{<index/item title="Covering indexes" body="Explore Covering indexes in YCQL with examples." href="covering-index-ycql/" icon="fa-thin fa-table-list">}}

{{<index/item title="Secondary indexes with JSONB" body="Create covering and partial indexes with JSONB columns." href="secondary-indexes-with-jsonb-ycql/" icon="fa-thin fa-list-ol">}}

{{</index/block>}}