What is a composite index and why does column order matter?
Model answer
An index on several columns. Order matters because it can be used for queries filtering on the leftmost columns: an index on (country, city) helps WHERE country = 'IN' and WHERE country = 'IN' AND city = 'Pune', but not city alone. Put equality columns first, then range or sort columns.
Learn this topic
Indexes and Faster Queries: EXPLAIN for Beginners in the course SQL for Beginners: Learn Databases Step by Step.
Sign in to add your own answer.