Why shouldn't we add indexes on every column of a small table with ten columns, even if it seems to speed up execution?
💡 Model Answer
Adding an index on every column of a small table may seem to improve query performance, but it actually introduces overhead that outweighs the benefits. Each index consumes disk space, increases write latency, and requires maintenance during inserts, updates, and deletes. Moreover, indexes are most effective when they match the predicates and join columns used by the workload. On a table with only ten columns, many of those columns will have low cardinality or be rarely used in WHERE clauses, so the optimizer will not benefit from an index. Unnecessary indexes can also cause the query optimizer to choose suboptimal plans because of inflated cardinality estimates. The right approach is to analyze the query workload, identify the most selective columns used in predicates or joins, and create targeted indexes—often composite or covering indexes—on those columns. This balances performance gains with maintenance costs.
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