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.

HardTechnical
52 practiced
A complex SQL query runs fast on a small dataset but is very slow on production. Provide a step-by-step plan: how you would profile and benchmark, what indexes or rewrites you would try, and example SQL for a likely index to add and a rewritten query. Explain how you would measure improvement.
EasyBehavioral
49 practiced
Tell me about a time when a database schema or design choice impacted the outcome of a project you worked on. Use the STAR format (Situation, Task, Action, Result) and emphasize how you analyzed the problem and what you would do differently.
MediumTechnical
79 practiced
Compare choosing PostgreSQL with a columnar extension (e.g., cstore_fdw), BigQuery, and Redshift for an analytics workload. Discuss criteria: concurrency, query latency, cost model, data freshness, maintenance, and when you'd prefer each option.
MediumTechnical
47 practiced
Given these tables and a heavy analytic query joining orders and order_items:
orders(id BIGINT PRIMARY KEY, created_at TIMESTAMP, status TEXT, customer_id BIGINT)order_items(id BIGINT PRIMARY KEY, order_id BIGINT, product_id BIGINT, price NUMERIC)
The query filters recent orders and groups by order id to compute totals. Propose concrete indexes (CREATE INDEX statements) to speed up the JOIN and aggregation, and justify them.
MediumTechnical
44 practiced
A product manager wants session data available with low latency while retaining sessions for 90 days. Evaluate storing active session state in Redis vs PostgreSQL. Consider cost, durability, consistency, eviction and TTL, hot-warm architecture, and fallback strategies.

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.