Home › Interview Questions › Can we apply indexing on multiple columns of a tab…

Can we apply indexing on multiple columns of a table? What happens if we apply indexing on many columns, like 56 columns? How does it affect query performance?

🟡 Medium Conceptual Junior level
1Times asked
Oct 2026Last seen
Oct 2026First seen

💡 Model Answer

Indexing multiple columns can dramatically speed up queries that filter on those columns, but it also adds write overhead and storage cost. A composite index (e.g., CREATE INDEX idx_user_date ON orders(user_id, order_date)) is useful when queries frequently filter on both columns together. However, if you create an index on every possible combination of columns, you’ll quickly exhaust disk space and slow down inserts, updates, and deletes. The key is to analyze query patterns: use the EXPLAIN plan to see which columns are most selective and which combinations are used together. Prefer covering indexes that include all columns needed for the query to avoid lookups. For high‑cardinality columns, a single‑column index is often sufficient; for low‑cardinality columns, avoid indexing them alone because they provide little filtering power. If you need to index many columns, consider partial indexes or filtered indexes that only cover a subset of rows. Also, remember that most databases limit the number of indexes per table (e.g., PostgreSQL allows up to 32). In practice, start with the most frequently used query predicates, monitor performance, and add or drop indexes as needed.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500