Sector file // sql
SQLDECODED.
Joins, indexes & queries
Easy
5 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 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
What is the difference between CHAR, VARCHAR, and TEXT?
DSA ยท 94 views ยท data-types
Medium
26 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
How do you read an EXPLAIN query plan?
DSA ยท 1.1k views ยท explain
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 do you aggregate values into a single string?
DSA ยท 1.1k views ยท string-agg
Hard
11 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
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 optimize a slow SQL query?
DSA ยท 816 views ยท query-optimization
Why does column order matter in a composite index?
DSA ยท 585 views ยท composite-index
pgvector cosine similarity index in 2025-26 โ HNSW vs IVFFlat for semantic search at scale?
System Design ยท 465 views ยท pgvector, hnsw, cosine-search
What is a deadlock and how do you prevent it?
DSA ยท 366 views ยท deadlock
Seen a SQL question that is not here? Add it and help the next candidate.
Share a question