Sector file // sql
SQLDECODED.
Joins, indexes & queries
Easy
14 questionsWhat is the difference between a primary key and a foreign key?
DSA ยท 1.2k views ยท primary-key, foreign-key
What is the difference between a primary key and a unique constraint?
DSA ยท 1.1k views ยท constraints
What is the logical order of execution of a SQL query?
DSA ยท 1.1k views ยท order-of-execution
What is the CASE expression?
DSA ยท 1.0k views ยท case
What is the difference between WHERE and HAVING?
DSA ยท 1.0k views ยท where, having
What does DISTINCT do and what is its cost?
DSA ยท 859 views ยท distinct
How do you find duplicate rows in a table?
DSA ยท 694 views ยท duplicates, group-by
When would you use a transaction explicitly?
DSA ยท 604 views ยท truncate-vs-delete
Medium
43 questionsTop-N per group with RANK() OVER (PARTITION BY) โ how do you get top 2 per department without collapsing rows?
DSA ยท 1.2k views ยท window-functions, rank, partition
Advanced UPSERT patterns โ conditional updates, xmax detection, and soft-delete-aware indexes?
System Design ยท 1.2k views ยท upsert, idempotency, constraints
Covering indexes (INCLUDE) and Bitmap Heap Scans โ how do you eliminate heap fetches in 2025?
System Design ยท 1.2k views ยท covering-index, bitmap-scan, vacuum
What is a subquery and what is a correlated subquery?
DSA ยท 1.2k views ยท subquery
LATERAL JOIN โ how do you fetch the top 3 orders per customer efficiently?
DSA ยท 1.1k views ยท lateral-join, top-n, postgres
What is a covering index?
DSA ยท 1.1k views ยท covering-index
How does GROUP BY work with aggregate functions?
DSA ยท 1.1k views ยท group-by, aggregate
What are COMMIT, ROLLBACK, and SAVEPOINT?
DSA ยท 1.1k views ยท transactions
Hard
14 questionsSerializable isolation pitfalls โ write skew, retry storms, and when advisory locks beat SSI?
System Design ยท 1.1k views ยท isolation, serializable, write-skew
JSONB vs normalized columns vs EAV โ how do you model flexible attributes without killing query performance?
System Design ยท 1.1k views ยท jsonb, data-modeling, schema-design
RANK() vs DENSE_RANK() vs ROW_NUMBER() โ when does the gap matter and how do you choose?
DSA ยท 1.1k views ยท window-functions, ranking, dense-rank
How do recursive CTEs work?
DSA ยท 1.1k views ยท recursive-cte
What is a LATERAL join?
DSA ยท 970 views ยท lateral
SKIP LOCKED for job queues โ how do you build a concurrent queue without race conditions?
System Design ยท 857 views ยท skip-locked, queue, concurrency
How do you pivot rows into columns?
DSA ยท 651 views ยท pivot
Why does column order matter in a composite index?
DSA ยท 585 views ยท composite-index
Seen a SQL question that is not here? Add it and help the next candidate.
Share a question