Different types of indexes
Based on the query pattern and columns in the table, you should decide what kind of index is going to help with the performance.
The following are the types of indexes available in CockroachDB:
- Primary index
- Secondary index
- Hash-sharded index
- Duplicate indexes
- Inverted indexes
- Partial indexes
- Spatial indexes
- Table joins and indexes
- Best practices while using indexes
In the next set of subsections, we are going to discuss each type of index and when to use them, starting with the primary index.
Primary indexes
A primary key uniquely identifies a given row in a table. This means that the primary key is unique for a given row and duplicate values or NULLs are not allowed. An index created for a primary key is called a primary index.
Whenever you create a table in CockroachDB, it's recommended to have an explicit primary key, so that CockroachDB automatically creates an index for it, which can...