PostgreSQL
39 questions in 12 subtopics.
Process architecture, shared buffers and WAL
Describe what happens inside PostgreSQL when a Java service opens a JDBC connection and runs an UPDATE that commits. Name the processes involved and where the changed row lives before and after commit.What is the write-ahead log (WAL) in PostgreSQL, and why does a crash right after COMMIT not lose the committed transaction even though the table file was never written?Write latency on a PostgreSQL 17 primary spikes every 5 minutes, and the log shows: 'LOG: checkpoints are occurring too frequently (24 seconds apart) HINT: Consider increasing the configuration parameter max_wal_size'. Explain what is going on and how you would tune it.Your company runs 60 PostgreSQL clusters on cloud VMs, each tuned by hand. Design the standard for storage, WAL and backup layout so that any cluster can be restored to a point in time and the on-call team understands all of them the same way.PostgreSQL uses a process per connection and a shared buffer pool on top of the operating system page cache, a design from the 1980s and 1990s. How do these choices shape what your engineering organisation must standardise around it, and would you bet on PostgreSQL as the default database for the next ten years?VACUUM and autovacuum
Why does PostgreSQL need VACUUM at all, and what is the difference between VACUUM, VACUUM FULL and autovacuum?A queue tablejobs(id, status, payload) receives 2,000 inserts and 2,000 deletes per second. The table holds about 10,000 live rows, but its size grew to 40 GB and SELECT ... WHERE status = 'NEW' LIMIT 10 FOR UPDATE SKIP LOCKED became slow. What is happening and what would you check?Autovacuum on your largest table (3 billion rows) runs for 18 hours, is cancelled by a nightly DDL job, and restarts from scratch. Bloat and wraparound age keep growing. What would you change?Define how vacuum health is monitored and owned across 40 product teams that each own their own PostgreSQL schemas on shared clusters.Tuple visibility and xmin
Every PostgreSQL row version has hidden columns xmin and xmax. Explain what they hold and how a SELECT decides whether it can see a row version.A reporting session started BEGIN ISOLATION LEVEL REPEATABLE READ at 09:00 and has been idle in transaction for six hours. Explain what it does to the rest of the database and how you would find and prevent it.Analysts want to run 30-minute queries against the production primary, and the product team fears bloat and conflicts. Lay out the options PostgreSQL offers and which one you would choose for a company with 200 services.Transaction ID wraparound
What is transaction ID wraparound in PostgreSQL, and what does freezing do to prevent it?Monitoring showsage(datfrozenxid) for your main database at 1.6 billion and rising, and the warning 'database must be vacuumed within 400000000 transactions' is near. What is your plan during the next hours?A well-known outage pattern is a PostgreSQL database stopping writes because of transaction ID wraparound after years of growth. As the person accountable for data platforms, how do you make sure such slow-moving risks are caught across the company, not just this one?JSONB
Tableorders(id bigint, data jsonb). Write queries to (a) find orders whose data contains {"status": "PAID"}, (b) get the customer email at data -> 'customer' -> 'email' as text, and (c) create an index that makes (a) fast.A team proposes storing all product attributes in a single jsonb column instead of relational columns, to avoid migrations. Review the proposal: where is jsonb right, and where will it hurt?Several teams use PostgreSQL jsonb columns as a document store instead of adopting MongoDB. How do you set a policy on when jsonb is acceptable across the company?Extensions
What is a PostgreSQL extension? Name four widely used extensions and what problem each solves.You must add semantic search over 20 million product descriptions. Compare using the pgvector extension in your existing PostgreSQL with a dedicated vector database.Extensions are one reason PostgreSQL won wide adoption, but every extension you allow ties you to a version, a vendor or a managed provider. How would you govern extensions across the company?Declarative partitioning
Write DDL for an events table partitioned by month on created_at, with a partition for January 2026 and a default partition. Then explain what partition pruning is.A 4 TB orders table has queries filtered by customer_id and by created_at, and old data must be deleted after 7 years. Would you partition it, and by what key? How would you migrate the live table?Design a partitioning standard for multi-tenant SaaS data in PostgreSQL where 5 tenants are huge and 5,000 are small.Streaming and logical replication
Compare PostgreSQL physical streaming replication with logical replication. What does each copy, and what can the subscriber do?The primary's disk filled up overnight because pg_wal grew to 900 GB. SELECT slot_name, active, restart_lsn FROM pg_replication_slots shows a slot named debezium_old with active = f. Explain the cause and the fix.Your Spring service reads from a streaming replica to offload the primary. Users sometimes save a profile and then see the old value. What is going on and what are your options?Design high availability for a PostgreSQL cluster that backs payments: RPO zero, failover within 30 seconds, and two availability zones plus a third for quorum.Configuration tuning
A new PostgreSQL 17 server has 64 GB of RAM and is used by a Spring Boot service. Which memory settings would you look at first and what are reasonable starting values?EXPLAIN (ANALYZE, BUFFERS) on a reporting query shows 'Sort Method: external merge Disk: 1840000kB' and the query takes 40 seconds. What do you change, and what do you avoid changing?How would you manage PostgreSQL configuration for 100 clusters of different sizes in a consistent and reviewable way?PgBouncer and connection limits
Why do PostgreSQL deployments often put PgBouncer between applications and the database even when every Spring Boot service already has a HikariCP pool?After putting PgBouncer in transaction mode in front of a Spring Boot service using the PostgreSQL JDBC driver, errors appear: 'ERROR: prepared statement "S_3" does not exist'. Explain and fix.Connection storms after deployments push a shared PostgreSQL cluster to max_connections and cause outages for other teams. Design connection management for 150 services sharing a few clusters.TOAST
What is TOAST in PostgreSQL, and what happens when you insert a row with a 200 KB text column?An API reads orders with a 500 KB jsonb document each. Updating only the status column of an order takes far longer than expected and WAL volume is high. Explain the role of TOAST and what you would change.Upgrades between major versions
What are the main ways to upgrade PostgreSQL from version 15 to 17, and why can you not just install new binaries over the old data directory?Plan a near-zero-downtime upgrade of a 3 TB PostgreSQL 14 database behind a Spring Boot fleet to PostgreSQL 17 using logical replication.Your company has 300 PostgreSQL databases on versions 11 to 17, several past end of life. How do you build an upgrade programme that stops this from happening again?No question matches these choices.