Skip to content

Boarding pass · PostgreSQL Advanced

PostgreSQL · Advanced interview

An AI mock interview for senior engineers working with PostgreSQL. Reason about the query planner and performance, concurrency and locking, replication and scaling, and production operations.

20–30 minEstimated6 questionsTailored live12 model answersTo study
  • Voice interview
  • Live feedback
  • Browser-only
  • No installation required

Your report · sample

AI Readiness Score

/100
Content score English score

Finish the mock and get this report — scored on content and English, with concrete tips and a model answer for every question, plus a study plan.

Your flight path

Five steps to interview-ready.

From a quick warm-up to a personalised study plan — here's the whole loop, and what you get at each gate.

  1. Step 01

    Preparation

    Skim the topics and warm up — you're briefed before takeoff.

  2. Step 02

    AI Interview

    A realistic AI interviewer asks tailored questions — answer by voice or text.

  3. Step 03

    Instant Score

    Finish and get a 0–100 readiness score across content and English.

  4. Step 04

    AI Feedback

    Concrete tips and a rewritten model answer for every response.

  5. Step 05

    Study Plan

    A personalised plan targets your weakest areas — so the next run scores higher.

Preview the AI demo

See one answer scored, end to end.

The whole loop on sample data — question, your answer, instant feedback and a study plan. Hover to pause.

aevrofy.com/session · live demoPlaying

Interviewer · Question 1

“Tell me about yourself.”

Who it's for

  • Senior backend and database engineers
  • Engineers who tune and operate Postgres
  • Anyone targeting senior data-platform roles
  • Devs who own Postgres performance and HA

What you'll practice

  • Reading plans and tuning the planner
  • Locking, MVCC internals and deadlocks
  • Replication, partitioning and pooling
  • VACUUM tuning, backups and failover

Topics covered

What this level expects.

Performance

  • Plan reading
  • Statistics & cost
  • Index-only & bloat

Concurrency

  • Lock types
  • MVCC internals
  • Deadlocks & FOR UPDATE

Scaling

  • Replication
  • Partitioning
  • Connection pooling

Operations

  • VACUUM tuning
  • Backups & PITR
  • High availability

Practice questions

12 questions, with model answers.

Read them, then run the live mock to answer out loud and get scored. Tap any question to reveal a model answer.

01How do you read a Postgres execution plan and tune a slow query?

EXPLAIN (ANALYZE, BUFFERS) shows the plan tree with node types (Seq Scan, Index Scan, Nested Loop, Hash Join), estimated vs actual rows, timing, and buffer hits. You look for sequential scans on large tables, row-estimate mismatches (stale stats — run ANALYZE), expensive sorts spilling to disk (raise work_mem), and nested loops over large sets. The fix is usually a better index, rewritten predicate (sargable), or updated statistics — verified by re-running the plan.

02How do table statistics affect the planner?

The planner is cost-based: it estimates row counts and costs using statistics gathered by ANALYZE (value distributions, most-common-values, histograms, n_distinct). If stats are stale or a column is skewed/correlated, estimates go wrong and it picks bad plans (e.g. a nested loop over millions of rows). You fix this by running ANALYZE, increasing the statistics target for skewed columns, or adding extended statistics for correlated columns.

03What is an index-only scan, and how does bloat affect it?

An index-only scan answers a query from the index alone when all needed columns are present and the visibility map shows the pages are all-visible, avoiding heap fetches. Bloat (dead tuples from MVCC) and an out-of-date visibility map force heap visits, undermining the optimization. Keeping autovacuum healthy maintains the visibility map so index-only scans stay effective — another reason bloat hurts read performance.

04What lock types matter in Postgres and how does contention arise?

Postgres uses row-level locks (acquired by UPDATE/DELETE/SELECT FOR UPDATE) and table-level locks (e.g. ACCESS EXCLUSIVE taken by some DDL). Reads don't block writes thanks to MVCC, but conflicting writes to the same rows serialize, and DDL like ALTER TABLE can block all access briefly. Contention shows up as queries waiting on locks (pg_locks, pg_stat_activity); you reduce it with short transactions and careful, concurrent-friendly migrations (e.g. CREATE INDEX CONCURRENTLY).

05What is transaction-id wraparound and how do you prevent it?

Postgres uses 32-bit transaction ids to determine row visibility; if the oldest un-vacuumed transactions aren't frozen before the id counter wraps, data could appear to vanish — so Postgres forces aggressive anti-wraparound vacuums and ultimately refuses new transactions to protect data. You prevent it by ensuring autovacuum keeps up (especially on large/old tables), avoiding extremely long-running transactions that hold back the freeze horizon, and monitoring age(datfrozenxid).

06How do deadlocks happen and how do you handle SELECT FOR UPDATE?

A deadlock arises when two transactions each hold a lock the other needs; Postgres detects the cycle and aborts one with a deadlock error. SELECT ... FOR UPDATE takes row locks to implement safe read-modify-write (preventing lost updates), with NOWAIT or SKIP LOCKED variants for queue-like patterns. You avoid deadlocks by locking rows in a consistent order, keeping transactions short, and adding retry logic for the aborted one.

07How does streaming replication work, and what are its trade-offs?

The primary streams its write-ahead log (WAL) to one or more standbys that replay it, giving near-real-time replicas for read scaling and failover. Asynchronous replication is fast but a standby can lag (potential data loss on failover); synchronous replication waits for a standby to confirm, guaranteeing durability at the cost of write latency. You route read-only traffic to replicas while accepting eventual consistency from lag.

08How does declarative partitioning help, and what are the gotchas?

Declarative partitioning splits a big table by range/list/hash into child partitions; the planner prunes to only relevant partitions, speeding queries and making bulk data lifecycle (dropping an old time partition) cheap. Gotchas: queries must include the partition key to benefit from pruning, indexes and constraints are per-partition, and too many partitions add planning overhead. It's most valuable for large time-series or clearly-partitionable data.

09Why do you need a connection pooler like PgBouncer?

Each Postgres connection is a backend process with real memory overhead, so thousands of direct app connections exhaust resources and degrade performance. PgBouncer sits in front and multiplexes many client connections onto a small pool of server connections. Its modes (session, transaction, statement) trade feature compatibility for efficiency — transaction pooling is common and very efficient but disallows session-level features like prepared statements without care.

10How do you tune autovacuum for a busy database?

Monitor for bloat and lagging vacuums (dead tuple counts, last_autovacuum). On high-write tables, lower the autovacuum_vacuum_scale_factor (so it triggers sooner), increase autovacuum workers and cost limits so it runs faster, and set per-table storage parameters for hot tables. The goal is to reclaim dead tuples before bloat and wraparound become problems, balanced against the I/O autovacuum itself consumes.

11How do backups and point-in-time recovery work in Postgres?

A base backup (pg_basebackup) plus continuously archived WAL lets you restore to the base and replay WAL up to any moment — point-in-time recovery (PITR) — which is invaluable for recovering from an accidental delete or corruption. Logical backups (pg_dump) are portable, per-database/table snapshots good for migrations but slower to restore at scale. A solid strategy combines regular base backups, WAL archiving, and tested restores.

12How do you achieve high availability and failover with Postgres?

Run one or more standbys via streaming replication and use a tool like Patroni (with etcd/Consul) or repmgr to automate leader election and failover, promoting a standby when the primary fails, fronted by a virtual IP or a proxy/HAProxy so clients reconnect transparently. Synchronous standbys bound data loss (RPO); automated failover bounds downtime (RTO). You also fence the old primary to avoid split-brain and test failover regularly.

Preparation tips

Walk in ready.

  • Be able to spot a bad row estimate in a plan
  • Know why long-running transactions block VACUUM
  • Explain PgBouncer pooling modes
  • Have a PITR/backup strategy ready

Ready for the real thing?

Run a 6-question PostgreSQL mock interview, answer out loud, and get a readiness score with tips and model answers.

More advanced interviews

Aevrofy · PostgreSQL advanced interview prep