InterviewStack.io LogoInterviewStack.io

Database Design and Query Optimization Questions

Principles of database schema design and performance optimization including relational and non relational trade offs, normalization and denormalization, indexing strategies and index types, clustered and non clustered indexes, query execution plans, common table expressions for readable complex queries, detecting missing or redundant indexes, sharding and partitioning strategies, and consistency and availability trade offs. Candidates should demonstrate knowledge of optimizing reads and writes, diagnosing slow queries, and selecting the appropriate database model for scale and consistency requirements.

MediumTechnical
56 practiced
SQL rewrite: Given table `events(user_id int, created_at timestamptz, type text)` and the query `SELECT * FROM events WHERE type = 'click' OR type = 'view' AND created_at > now() - interval '7 days'`, explain why this may avoid indexes and rewrite the query to ensure index usage and correct logical semantics. Use PostgreSQL syntax.
MediumTechnical
55 practiced
Index maintenance and writes: Explain how having many indexes affects insert, update, and delete performance. Describe mitigation strategies (deferred index creation, partial indexes, batched writes, disabling indexes during bulk loads) and how to balance read optimization with acceptable write latency.
EasyTechnical
58 practiced
Explain the difference between primary keys, unique constraints, and indexes in relational databases. Include how each is implemented conceptually, how they affect performance for reads and writes, and when you would use a unique index versus a non-unique index versus a primary key.
EasyTechnical
43 practiced
Explain when and why to create composite (multi-column) indexes. Discuss index column order, left-prefix behavior, and provide an example where reversing column order changes whether an index is used for a given query.
HardSystem Design
42 practiced
Design (hard): Architect a scalable metadata store for a SaaS product that will store billions of small metadata records (key, value, tenant_id, created_at) and must serve 100k QPS of read traffic for recent data and 10k QPS of writes. Describe database choice(s), schema, indexing, partitioning/sharding, caching layer, archival, and how you'd ensure efficient queries for tenant-scoped reads and point lookups.

Unlock Full Question Bank

Get access to hundreds of Database Design and Query Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.

40+ Database Design and Query Optimization Interview Questions & Answers (2026) | InterviewStack.io