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.

HardSystem Design
53 practiced
You must design the backend for a social feed (personalized timelines) with heavy reads, personalization, and eventual consistency for likes/comments. Compare using relational schemas, denormalized feed fan-out (push), fan-in (pull), stream processing, caching layers, and selection of primary database technologies. Make a recommendation and justify it for low-latency global reads.
EasyTechnical
57 practiced
Large OFFSET queries slow down pagination. As a Solutions Architect, describe efficient pagination approaches for APIs with large result sets (e.g., millions of rows). Include examples of keyset (cursor) pagination and strategies when sorting by multiple columns is required.
MediumTechnical
56 practiced
Write a PostgreSQL SQL query using a CTE and window functions to return the top 3 highest spending users per month from transactions(transaction_id, user_id, amount, occurred_at). Return columns: month, user_id, month_total, rank. Explain performance considerations for large datasets.
MediumTechnical
50 practiced
You are given this schema: orders(order_id, customer_id, created_at, total), order_items(order_item_id, order_id, product_id, qty, price). A slow query joining orders and order_items is running. Describe how you would use an execution plan (EXPLAIN) to diagnose the bottleneck and list specific index changes or query rewrites that commonly fix join performance issues.
MediumTechnical
79 practiced
A production database shows slow transactional throughput. Describe the methodical steps you would take to determine whether the cause is CPU, disk IO, network, lock contention, or poor query plans. List specific metrics, system views, and tools you would use and what thresholds or signals you would look for.

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.