Interview Question

What is composite index?

A composite index uses an ordered list of columns.

💡 Concept ✅ Quick Revision 🗃️ SQL

Answer

A composite index indexes more than one column in a defined order. • It can support queries using its leading columns. • Column order affects which predicates and orderings it can serve efficiently. • Duplicate indexes should be avoided because each adds maintenance cost.

💡 SQL Example

CREATE INDEX orders_customer_date_idx ON orders (customer_id, ordered_at);

Result

CREATE INDEX

⚡ Quick Revision

A composite index uses an ordered list of columns.