Senior
When is an index not advantageous?
sobes.tech AI
Answer from AI
An index is not beneficial when:
- The table is very small — a full scan is faster than using an index.
- Queries return a large portion of the table's rows (for example, more than 30-40%), then the index is inefficient.
- Frequent insert, update, or delete operations, as indexes slow down these operations due to the need to update them.
- The index is created on a column with low selectivity (few unique values), such as boolean fields.
- Functions or expressions are used on indexed columns, making the index unusable.
Example: if you have a table with 100 rows, and you run a query that returns 80 of them, using an index will be slower than just scanning the entire table.