TOPIC-WISE INTERVIEW PRACTICE

PostgreSQL interview questions and quick answers

Indexes, EXPLAIN, transactions and isolation, JSONB and the Postgres specifics backend interviews probe.

Review 951 questions and short answers on PostgreSQL. Start with real examples below, then search, practise and follow links to full explanations.

951 questionsFree revision22 topics
START HERE

PostgreSQL: questions worth revising first

These answers come from AI Tapri's existing question bank and published interview guides. Open each answer and read the linked in-depth guide for examples and context.

01What are advisory locks in PostgreSQL and when would you use one?

Advisory locks are application-defined locks on an arbitrary number, managed by PostgreSQL but not tied to any table or row. Use them to make sure only one process runs a task, like a nightly report job, at a time.

Read the full explanation
02What happens when you run ALTER TABLE ... ALTER COLUMN TYPE on a large table?

In most cases PostgreSQL rewrites the whole table while holding an ACCESS EXCLUSIVE lock, so reads and writes wait. Only some changes, such as widening varchar or dropping a length limit, skip the rewrite.

Read the full explanation
03What is a BRIN index and when is it better than B-tree?

BRIN stores only the minimum and maximum value for each block range of the table, so it is tiny. It works well on huge tables where the column's value follows the physical row order, like an append-only timestamp.

Read the full explanation
04Does the column order in a multi-column B-tree index matter?

Yes. A composite index is sorted by the first column, then the second within it, and so on. It helps queries that filter on a leading prefix of its columns, and it is much less useful if only a later column is filtered.

Read the full explanation
05How do you use a CHECK constraint, and what does it ignore?

CHECK rejects a row when a boolean expression on its columns is false. It passes when the result is true or NULL, so pair it with NOT NULL when the column must always be present. It cannot see other rows.

Read the full explanation
06Why do too many connections hurt PostgreSQL, and how does a connection pooler like PgBouncer help?

Each PostgreSQL connection is a separate server process with its own memory, so thousands of mostly idle connections waste RAM and add CPU overhead. A pooler like PgBouncer lets many clients share a small number of real database connections, handing a connection to a client only while it runs a transaction.

Read the full explanation
07What is a common pitfall related to "What are advisory locks in PostgreSQL and when would you use one"?

Using session-level advisory locks through a transaction-mode pooler.

Read the full explanation
08How would you explain "What are advisory locks in PostgreSQL and when would you use one" in an interview?

"Advisory locks let an application lock an abstract key, for example to ensure one cron instance runs at a time. I use the transaction-scoped versions, especially behind PgBouncer, so locks are never leaked."

Read the full explanation
YOUR PRACTICE SPACE

Find your next answer.

Pick a topic, search a keyword, or open a question to reveal the answer.

951 questions available
POSTGRESQL

PostgreSQL quick answers

Showing 18 of 951
933 remaining

Free to practise. No account needed. Made for quick revision, not rote memorisation.

Keep preparing for PostgreSQL

Quick answers help with recall; detailed guides explain the reasoning, examples and common mistakes behind each answer.

More topics to practise