HomeInterview QuestionsThe table is queried by ID, but the ID is modified…

The table is queried by ID, but the ID is modified frequently.

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

💡 Model Answer

When a primary key or indexed column is updated frequently, the database must rewrite the index pages, causing fragmentation and cache misses. This degrades read performance. To mitigate this, use a surrogate key that never changes as the primary key and keep the business key (the ID that changes) as a non‑clustered index. If the ID must remain the primary key, consider using a clustered index on a stable column or a composite key that includes a timestamp. Additionally, enable automatic index maintenance (e.g., REINDEX in PostgreSQL, ALTER INDEX REBUILD in SQL Server) or schedule periodic vacuum/optimize operations in systems like Redshift. Finally, evaluate whether the frequent updates are necessary; sometimes denormalizing or archiving old data can reduce write contention.

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 — invisible to screen sharing.

Get Assisting AI — Starts at ₹500