Interview Q&A · questions with model answers

PostgreSQL Interview Questions

Part of the study plan for: Data Engineer

Ordered by how often they're asked. Most-asked answers are free to read in full; members see every answer and can rate their confidence on each.

  1. Most asked Which schema changes take heavy locks in PostgreSQL, and how do you avoid outages during migrations?

    Many ALTER TABLE forms take an ACCESS EXCLUSIVE lock, which blocks reads and writes. Even a fast DDL statement can cause an outage if it waits behind a long query, because every new query then…

  2. Most asked Why do PostgreSQL deployments need connection pooling, and how do PgBouncer's modes differ?

    PostgreSQL forks a backend process per connection, which costs memory and makes thousands of connections expensive (contention, context switching). PgBouncer lets many clients share a small number…

  3. Most asked How does declarative partitioning work in PostgreSQL, and when should you use it?

    A partitioned table is split into child tables by RANGE, LIST or HASH on a key. Queries filtering on the key touch only relevant partitions (pruning), and old data can be removed by detaching or…

  4. Most asked Which PostgreSQL extensions do you find most useful?

    pg_stat_statements (query performance statistics), pg_trgm (fuzzy text search), PostGIS (geospatial), pgvector (vector similarity search for embeddings), citext (case-insensitive text), pgcrypto,…

  5. How do you generate UUID keys in PostgreSQL, and which version should you use?

    gen_random_uuid() (built in since PostgreSQL 13) generates random UUIDv4 values; PostgreSQL 18 adds uuidv7(), which is time-ordered. Prefer time-ordered UUIDs (v7) for primary keys because random…

  6. When would you use array columns in PostgreSQL?

    For small, bounded lists that belong to the row and are read together, such as tags or role names, especially with a GIN index for 'contains' queries (tags @> ARRAY['urgent']). For lists you query…

  7. serial or identity columns? And how do sequences behave?

    Prefer GENERATED ALWAYS AS IDENTITY (SQL standard) over serial. Both use a sequence, but identity columns own their sequence cleanly, prevent accidental manual inserts (with ALWAYS), and have…

Was this page helpful?

Report a mistake