DEVPREP CODEX · #18
PostgreSQL Interview Questions
75 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).
TOTAL QUESTIONS
75
THEORY QUESTIONS
75
IMPLEMENTATION FOLIOS
0
FREE QUESTIONS
5 / Level
Easy Level·25 Questions Total
Foundations & Core Concepts
Q1What is PostgreSQL and what distinguishes it?
- Advanced open-source object-relational DB known for standards compliance, extensibility (custom types/extensions), and correctness.
- Standouts: rich indexing (B-tree/GIN/GiST/BRIN), full-text search, JSONB, window functions, MVCC without read locks, transactional DDL.
- Single license (PostgreSQL License), no paid editions — feature parity everywhere.
Q2What is a primary key and how does Postgres implement it?
- Uniquely identifies rows;
PRIMARY KEYcreates a unique B-tree index + NOT NULL implicitly. - One PK per table; choice of int/bigserial vs UUID trade-offs (size, ordering, fragmentation).
- PK index backs fast lookups; clustered tables don't exist like SQL Server — heap storage with index-organized access via the index only.
Q3What are the main differences between CHAR, VARCHAR and TEXT?
- CHAR(n): blank-padded fixed length (rarely desired).
- VARCHAR(n): variable with limit enforced.
- TEXT: unlimited — Postgres performance identical across all three; use TEXT + CHECK constraint for length when needed. Interview nugget: unlike other engines, there's NO performance penalty choosing TEXT.
Q4What does SERIAL vs IDENTITY vs UUID mean for keys?
SERIALlegacy pseudo-type creating sequence default;GENERATED ALWAYS AS IDENTITYSQL-standard preferred (protects against manual id inserts).- Sequences have gaps on rollback by design.
- UUIDv4 random → index bloat/fragmentation on big tables; UUIDv7/time-ordered mitigates. Choose bigint identity for internal high-write tables.
Q5What is NULL and how do IS NULL / COALESCE work?
- NULL = unknown/absent, not zero/empty string.
- Comparisons yield NULL (
WHERE col <> 'x'excludes NULLs!) — explicitIS NULL/IS NOT NULLrequired. COALESCE(a,b,c)first non-null;NULLIF(a,b)returns null when equal (divide-by-zero guard pattern).
20 More Easy Questions Locked
Unlock the complete PostgreSQL Easy question bank
Get instant access to all 25 questions, in-depth model answers, code sandboxes, and all 27+ technologies for a single one-time payment.
Unlock All — One-time payment · Lifetime access
Browse All PostgreSQL Questions by Difficulty
Easy25 Questions
Core concepts, definitions, basic syntax, and first principles expected in round 1 screening.
VIEW FULL LIST
Medium25 Questions
Real-world mechanisms, state management, edge cases, performance trade-offs, and practical coding.
VIEW FULL LIST
Hard25 Questions
Deep runtime internals, memory models, distributed design, concurrency failure modes, and architectural decisions.
VIEW FULL LIST
INTERNAL LINKING & DEPENDENCIES