Reputation: 13377
How do I know which index CockroachDB will select for my query? How do I make sure I’m not performing a full table scan?
Upvotes: 2
Views: 196
Reputation: 13377
This is a pretty lengthy topic; there's an entire blog post devoted to the subject, which might be the best source for understanding how it works in CockroachDB.
To see which indexes CockroachDB is using for a given query, you can use the EXPLAIN
statement, which will print out the query plan, including any indexes that are being used:
EXPLAIN SELECT col1 FROM tbl1;
If you'd like to tell the query planner which index to use, you can do so via some special syntax for index hints:
SELECT col1 FROM tbl1@idx1;
Upvotes: 2