PostgreSQL Interview Questions & Answers — Cracked Java
Cracked Java console
0
S
Modules/PostgreSQL
// MODULE · 15 TOPICS · 123 QUESTIONS

PostgreSQL

Relational database internals, query optimization, indexing, transactions, and operational concerns for backend interviews.

0%
Reviewed
0 / 123
Topics done
0 / 15
Est. time left
~40h
Next up
Relational Model & SQL Fundamentals
15 topics · tap to expand
01

Relational Model & SQL Fundamentals

JuniorNot started
02

Normalization & Schema Design

MidNot started

Normal forms walked through a concrete table, when denormalization pays off, modeling relationships and polymorphism, and surrogate vs natural keys including UUID v7.

01What are 1NF, 2NF, 3NF, BCNF? Walk a denormalized table through each form.Mid02When is denormalization the right choice? Trade-offs.Mid03How do you model a many-to-many relationship?Junior
03

PostgreSQL Data Types

JuniorNot started
04

Indexing — B-tree, Hash, GIN, GiST, BRIN

MidNot started

How each index type works and what it is for, composite and covering indexes, partial and expression indexes, the cost of indexing, and why the planner sometimes ignores an index.

01How does a B-tree index work? Why is it the default in PostgreSQL?Mid02When is a Hash index useful? Why was it rarely used before PostgreSQL 10?Mid03What is a GIN index used for? (Full-text search, JSONB, arrays.)Mid
05

Query Planning & EXPLAIN

SeniorNot started

Reading EXPLAIN output, the scan and join node types, how the planner chooses between them, finding slow queries with pg_stat_statements, and why Postgres has no planner hints.

01EXPLAIN vs EXPLAIN ANALYZE vs EXPLAIN (ANALYZE, BUFFERS, VERBOSE).Senior02Seq Scan vs Index Scan vs Index Only Scan vs Bitmap Heap/Index Scan.Senior03When does the planner choose Seq Scan over Index Scan?Senior
06

Transactions, ACID, Isolation Levels

SeniorNot started

ACID, the four isolation levels and the anomalies they prevent, what Read Committed actually guarantees, SSI Serializable, MVCC and row versions, and VACUUM and ID wraparound.

01What does ACID stand for? Define each property.Mid02The four isolation levels — what anomalies does each prevent?Senior03The four anomalies: Dirty Read, Non-Repeatable Read, Phantom Read, Serialization Anomaly.Senior
07

Locks & Concurrency

SeniorNot started

Table- and row-level lock modes, advisory locks, deadlock detection, investigating contention with pg_locks and pg_stat_activity, and SKIP LOCKED for safe job queues.

01Table-level lock modes — which statements take which?Senior02Row-level locks: FOR UPDATE, FOR NO KEY UPDATE, FOR SHARE, FOR KEY SHARE.Senior03Advisory locks — when are they useful?Mid
08

Window Functions & Advanced SQL

MidNot started

Window vs aggregate functions, ranking and offset functions, frame clauses, CTE materialization (the 12+ change), recursive CTEs, LATERAL joins, DISTINCT ON, and GROUPING SETS.

01Difference between aggregate functions and window functions?Mid02ROW_NUMBER() vs RANK() vs DENSE_RANK().Mid03LAG() and LEAD() — example use cases.Mid
09

JSON & JSONB

MidNot started

JSONB vs JSON, the access and containment operators, GIN indexing strategies, mutation functions, JSONPath, and when document columns beat normalized tables.

01Difference between JSON and JSONB. Which should you almost always use?Mid02-> vs ->> vs #> vs #>> operators.Mid03@>, <@, ?, ?&, ?| operators — what do they do?Mid
10

Full-Text Search

MidNot started

tsvector and tsquery, building a GIN-backed FTS index, the query-builder functions, ranking, language configurations, and when to reach for a dedicated engine instead.

01What is tsvector and tsquery?Mid02How do you build a full-text index? (GIN on to_tsvector(...).)Mid03@@, plainto_tsquery, phraseto_tsquery, websearch_to_tsquery.Mid
11

Partitioning

SeniorNot started

Declarative partitioning, range/list/hash strategies, partition pruning, default partitions, live attach/detach, subpartitioning, and the foreign-key and global-index gotchas.

01What is declarative partitioning? When was it introduced?Senior02Range, List, Hash partitioning — when to use each?Senior03Partition pruning — how does the planner skip partitions?Senior
12

Replication & High Availability

SeniorNot started

Physical vs logical replication, sync vs async streaming, replication lag and slots, WAL, publications/subscriptions, failover tooling, and PgBouncer pooling modes.

01Difference between physical and logical replication.Senior02Streaming replication — synchronous vs asynchronous.Senior03Replication lag — how do you monitor it?Senior
13

Backup, Recovery, PITR

SeniorNot started

Logical vs physical backups, pg_dump/pg_dumpall/pg_basebackup, point-in-time recovery and WAL archiving, the ecosystem tools, and why DR testing matters.

01pg_dump vs pg_dumpall vs pg_basebackup. When to use each.Senior02What is PITR (Point-in-Time Recovery)? How does it work?Senior03WAL archiving — archive_command, restore_command.Senior
14

Performance Tuning & Operations

SeniorNot started
15

Stored Procedures, Functions, Triggers

MidNot started

Functions vs procedures, the procedural languages, volatility categories, trigger types and timing, when triggers become a liability, return shapes, and SECURITY DEFINER.

01Difference between a function and a procedure in PostgreSQL.Mid02Function languages: SQL, PL/pgSQL, PL/Python, PL/V8.Mid03IMMUTABLE vs STABLE vs VOLATILE — what does each mean and how does the planner use them?Senior