Join waitlist
DBMSCommunity question

When does an index make queries slower?

Asked by Pooja Patel 1 month ago 2 answers 9 votes

I know indexes slow down inserts/updates and aren't useful on very small tables. Quiz had an option about "low cardinality columns" and I wasn't sure. What else?

2 answers

Farhan Ali1 month agoMost voted8

Low cardinality is a big one. Index on something like gender or status with 2-3 values: each value matches a huge part of the table, so using the index means jumping around to random rows. A sequential scan is faster, optimizers often just ignore that index.

Other ones: using a function on the column (WHERE LOWER(email) = ...) skips a normal index, and lots of indexes on a write-heavy table.

Gayathri Menon1 month ago3

the LOWER() thing got me in my project last sem. query was slow even with an index, took me two days to figure out

Related questions

Go deeper

Want the full explanation, not just an answer?

Structured lessons on DSA, core CS, Java and interview skills, each ending in a quiz so you know it stuck.