All questions
Showing of 42Explain the ACID properties in PostgreSQL.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
ACID names four guarantees a transaction gives. PostgreSQL provides them with constraints, multiversion concurrency control (MVCC) snapshots and its write-ahead log (WAL).
- Atomicity means a transaction is all or nothing. If any statement in it fails, PostgreSQL rolls the whole transaction back, and none of its changes ever become visible.
- Consistency means every transaction leaves the data valid. PostgreSQL enforces this with constraints such as primary keys, foreign keys and
CHECK. - Isolation means a transaction does not see the unfinished changes of others. PostgreSQL gives each statement an MVCC snapshot of the data.
- Durability means a committed change survives a crash. PostgreSQL records the change in the WAL and flushes that log to disk before
COMMITreturns.
Outside a BEGIN block, PostgreSQL runs each statement as its own transaction. Wrapping the transfer below in BEGIN and COMMIT makes its two updates one atomic unit.
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 1;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
COMMIT; -- Both operations succeed or both fail
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are the main PostgreSQL data types?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
PostgreSQL's main types cover numbers, text, and dates and times. It also stores binary data and JSON. Arrays, UUIDs and network addresses have their own types too.
- Whole numbers use
integerorbigint. Exact decimals usenumeric, also spelleddecimal, and approximate values userealordouble precision. - Text uses
char,varcharortext. Unlike in some other database systems,charhas no speed advantage in PostgreSQL. - Dates and times use
date,timeandtimestamp, and spans of time useinterval. booleanholdstrueorfalse, andbyteaholds binary data.jsonkeeps JSON as plain text, whilejsonbstores it in a binary form that is faster to query.- Arrays can hold any data type,
uuidstores universally unique identifiers, andinetandcidrstore IP addresses.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between PRIMARY KEY and UNIQUE constraints?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Both reject duplicate values, but a primary key also forbids NULLs, and a table can have only one. A table can have many UNIQUE constraints, and their columns accept NULLs.
- A primary key is the row's main identifier, and foreign keys usually point to it. PostgreSQL requires its values to be unique and not null.
- A
UNIQUEcolumn accepts many NULLs by default, because two NULLs never count as equal. From PostgreSQL 15, declaring itUNIQUE NULLS NOT DISTINCTallows only one NULL. - Both create a unique B-tree index automatically, and a foreign key can reference either one.
CREATE TABLE users (
id SERIAL PRIMARY KEY, -- Cannot be NULL
email VARCHAR(255) UNIQUE, -- Can have many NULLs
username VARCHAR(50) UNIQUE -- Multiple unique constraints allowed
);
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the difference between DELETE, TRUNCATE, and DROP.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
DELETE removes chosen rows, TRUNCATE empties the whole table, and DROP removes the table itself.
DELETEremoves the rows itsWHEREclause matches and firesON DELETEtriggers. The deleted rows stay on disk as dead rows untilVACUUMreclaims the space.TRUNCATEremoves every row without scanning the table, so it is faster and frees the disk space at once. It firesON TRUNCATEtriggers, notON DELETEtriggers, and it blocks all other access to the table.DROPremoves the table definition along with its data, indexes and constraints.
In PostgreSQL, all three can be rolled back inside a transaction, because schema changes such as DROP TABLE are transactional too. A ROLLBACK after BEGIN brings a dropped table back.
DELETE FROM users WHERE age < 18; -- Removes specific rows
TRUNCATE TABLE users; -- Removes all rows
DROP TABLE users; -- Removes table entirely
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is a foreign key and how does it work in PostgreSQL?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A foreign key is a column whose values must match a row in another table. PostgreSQL rejects any change that would break that link, which is called referential integrity.
CREATE TABLE departments (
dept_id SERIAL PRIMARY KEY,
dept_name VARCHAR(100)
);
CREATE TABLE employees (
emp_id SERIAL PRIMARY KEY,
emp_name VARCHAR(100),
dept_id INTEGER REFERENCES departments(dept_id)
);
Here every employees.dept_id must name an existing department or be NULL. PostgreSQL enforces the link in three ways.
- An
INSERTorUPDATEthat sets adept_idwith no matching department fails. - Deleting a department that employees still reference fails by default, which is
ON DELETE NO ACTION. ON DELETE CASCADEdeletes the referencing employees instead, andON DELETE SET NULLsets theirdept_idtoNULL.
The referenced column must be a primary key or have a unique constraint. PostgreSQL does not index the referencing column for you, so a delete from departments must search employees unless you index employees.dept_id.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are indexes and why are they important?
What is the difference between SERIAL and identity columns in PostgreSQL?
Explain different types of JOINs in PostgreSQL with examples.
Explain the difference between UNION and UNION ALL.
What are Common Table Expressions (CTEs) and when would you use them?
Explain window functions and provide practical examples.
What is the difference between a view and a materialized view?
Explain PostgreSQL transaction isolation levels.
What are stored procedures and functions in PostgreSQL?
Explain triggers and provide a practical example.
What is MVCC and how does it work in PostgreSQL?
What is PostgreSQL connection pooling and how does PgBouncer work?
How do you add an index to a busy table without blocking writes?
What row-level locks does PostgreSQL offer, and when do you use SELECT FOR UPDATE?
What are PostgreSQL extensions and name some important ones?
Explain JSON and JSONB data types and their differences.
What are database roles and how do you implement role-based access control?
Explain PostgreSQL's query execution plan and how to optimize queries.
What is table partitioning and when should you use it?
Explain different types of indexes in PostgreSQL and their use cases.
Explain PostgreSQL replication types and their use cases.
What are the key considerations for PostgreSQL security?
Explain VACUUM, ANALYZE, and REINDEX in PostgreSQL.
How do you handle deadlocks in PostgreSQL?
Explain Write-Ahead Logging (WAL) and its importance.
What are the best practices for PostgreSQL backup and recovery?
How do you monitor and troubleshoot PostgreSQL performance?
Explain PostgreSQL's approach to handling large objects and binary data.
Explain PostgreSQL's foreign data wrappers (FDW).
How do you implement custom aggregates and operators in PostgreSQL?
What is logical decoding and how is it used?
How do you implement database sharding strategies in PostgreSQL?
How do you implement audit logging in PostgreSQL?
What is transaction ID wraparound in PostgreSQL, and how do you prevent it?
What is a HOT update in PostgreSQL, and how does fillfactor help?
What is an index-only scan, and what does it need to work?
How do you upgrade PostgreSQL to a new major version?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
PostgreSQL in pictures.
A quick recap of PostgreSQL in 31 short animated pictures, one idea at a time. About 8 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 27 pictures come with Pro.
This picture is part of Pro. The first chapter is free to play; the other 27 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in37 of 42 PostgreSQL answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.