Back to Tech Interviews

PostgreSQL Database Interview Master

100+ PostgreSQL interview questions covering MVCC concurrency, VACUUM tuning, GIN/GiST/BRIN indexes, CTEs, Window Functions, and Partitioning.

Total: 100 QuestionsLearned: 0 / 100 (0%)
Difficulty Filters

Tools & Options
Showing 100 of 100 questions
Beginner
What is PostgreSQL?

PostgreSQL is a powerful, open-source object-relational database system (ORDBMS) with over 35 years of active development. It is known for its reliability, feature robustness, and performance. It supports both SQL and JSON querying and is highly extensible.

Beginner
What are the key features of PostgreSQL?

Key features include:

1. **ACID Compliance**: Ensures reliable transactions.

2. **Conjoined Scalability**: Support for complex queries and large data volumes.

3. **Extensibility**: Custom types, functions, and operators.

4. **Advanced Data Types**: JSONB, HSTORE, Arrays, Ranges.

5. **MVCC**: Multi-Version Concurrency Control for high performance.

Beginner
What is the difference between PostgreSQL and MySQL?

- **MySQL**: Traditional RDBMS, focused on speed and simplicity, traditionally better for read-heavy web apps.

- **PostgreSQL**: ORDBMS, focused on compliance and advanced features, better for complex queries, high concurrency, and technical data types like JSONB.

Beginner
What is a Schema in PostgreSQL?
Beginner
How do you create a table in PostgreSQL?
Beginner
What is the SERIAL data type?
Beginner
How do you insert a row into a table?
Beginner
What is the purpose of the 'psql' utility?
Beginner
How do you list all tables in 'psql'?
Beginner
How do you see the structure of a table in 'psql'?
Beginner
What is a Primary Key?
Beginner
What is a Foreign Key?
Beginner
Explain the 'LIMIT' and 'OFFSET' clauses.
Beginner
How do you update data in a table?
Beginner
How do you delete data from a table?
Beginner
What is the 'TRUNCATE' command?
Beginner
What is a View in PostgreSQL?
Beginner
What is an Index?
Beginner
What is the 'WHERE' clause used for?
Beginner
What is the 'GROUP BY' clause?
Beginner
Explain 'INNER JOIN' vs 'LEFT JOIN'.
Beginner
What is the 'COALESCE' function?
Beginner
What is the purpose of 'VACUUM'?
Beginner
What is 'COPY' command for?
Beginner
What is the default port for PostgreSQL?
Intermediate
What is a Window Function in PostgreSQL?
Intermediate
What is a CTE (Common Table Expression)?
Intermediate
Explain the 'EXPLAIN' and 'EXPLAIN ANALYZE' commands.
Intermediate
What is MVCC (Multi-Version Concurrency Control)?
Intermediate
What are the differences between JSON and JSONB?
Intermediate
What is a GIN Index?
Intermediate
What is a Partial Index?
Intermediate
How do you perform a recursive query in PostgreSQL?
Intermediate
What is the 'UPSERT' (INSERT ON CONFLICT) operation?
Intermediate
What are the different isolation levels in PostgreSQL?
Intermediate
What is an extension in PostgreSQL?
Intermediate
Explain the 'RETURNING' clause in PostgreSQL.
Intermediate
What is a Materialized View?
Intermediate
How do you generate a UUID in PostgreSQL?
Intermediate
What is 'ILIKE'?
Intermediate
Explain the 'OVER' clause.
Intermediate
What are Savepoints in a transaction?
Intermediate
What is a Sequence in PostgreSQL?
Intermediate
What is the difference between 'VARCHAR' and 'TEXT'?
Intermediate
What is 'hstore'?
Intermediate
How do you handle character encoding in PostgreSQL?
Intermediate
What is the 'DISTINCT ON' clause?
Intermediate
What is a TRIGGER in PostgreSQL?
Intermediate
Explain 'CAST' and the '::' shorthand.
Intermediate
What is the 'pg_stat_activity' view?
Advanced
Explain PostgreSQL Partitioning.
Advanced
What is BRIN (Block Range Index)?
Advanced
Explain GIST (Generalized Search Tree) vs GIN.
Advanced
What is Table Inheritance?
Advanced
What are Logical and Physical Replication?
Advanced
Explain 'Vacuum Full' vs 'Vacuum'.
Advanced
What are Foreign Data Wrappers (FDW)?
Advanced
Explain the 'WAL' (Write-Ahead Logging).
Advanced
What is an Advisory Lock?
Advanced
What is JIT (Just-In-Time) compilation in Postgres?
Advanced
How do you handle Deadlocks in PostgreSQL?
Advanced
What is 'Streaming Replication'?
Advanced
Explain 'Work Mem' and 'Maintenance Work Mem'.
Advanced
What is a Bloom Index?
Advanced
Explain 'HOT' (Heap Only Tuple) updates.
Advanced
What is 'pg_dump' vs 'pg_dumpall'?
Advanced
How to find slow queries in PostgreSQL?
Advanced
What is 'Postgis'?
Advanced
Explain 'Declarative Partitioning'.
Advanced
What is 'Index Scan' vs 'Bitmap Index Scan' vs 'Sequential Scan'?
Advanced
What is 'Checkpointer' process?
Advanced
What is 'Schema Search Path'?
Advanced
How to optimize queries with JSONB data?
Advanced
Explain 'LISTEN' and 'NOTIFY'.
Advanced
What is 'Parallel Query' execution?
Scenario
Scenario: How to find the second highest salary without using LIMIT?
Scenario
Scenario: How to delete duplicate rows from a table while keeping the one with the lowest ID?
Scenario
Scenario: How to find the average salary by department, and only show departments with an average > 50000?
Scenario
Scenario: How to perform a case-insensitive search for a username?
Scenario
Scenario: How to query a JSONB column to find rows where a specific key exists?
Scenario
Scenario: How to query a JSONB column to find rows where a key has a specific value?
Scenario
Scenario: How to combine first_name and last_name with a space in between?
Scenario
Scenario: How to get the first 5 characters of a string?
Scenario
Scenario: How to prevent a division by zero error in a query?
Scenario
Scenario: How to find the nth most recent login for each user?
Scenario
Scenario: How to update multiple rows with different values in a single query?
Scenario
Scenario: How to copy only the structure of a table without any data?
Scenario
Scenario: How to find rows where a column's value is between 10 and 20 (inclusive)?
Scenario
Scenario: How to handle auto-incrementing IDs for a table created from a CSV with existing IDs?
Scenario
Scenario: How to find the current database name?
Scenario
Scenario: How to get the size of a database?
Scenario
Scenario: How to find which processes are currently blocking a specific table?
Scenario
Scenario: How to kill a slow-running query process?
Scenario
Scenario: How to generate a range of numbers (1 to 10)?
Scenario
Scenario: How to convert a comma-separated string into rows?
Scenario
Scenario: How to get the difference between two timestamps in hours?
Scenario
Scenario: How to find all columns in a specific table using SQL?
Scenario
Scenario: How to find the running total of sales over time?
Scenario
Scenario: You need to store multiple IP addresses in a single column and query them efficiently. Solution?
Scenario
How to export a table to a CSV file?

Technical Interview Mastery Blueprint

Proven methodologies and frameworks to succeed in technical and architecture rounds.

1. The Engineering STAR Technique

When responding to architectural or situational questions, structure your answer using Situation, Technical Constraint, Action, and Measurable Result. Rather than jumping straight to syntax, articulate the business problem, why certain patterns (e.g. caching, queuing, immutability) were selected over alternatives, and what latency or throughput improvements were achieved.

2. Defending Architectural Trade-Offs

Senior interviewers evaluate how you weigh trade-offs. Always explain why you chose an approach: e.g., memory overhead vs CPU cycle speed, consistency vs availability (CAP theorem), or normalized schemas vs denormalized fast reads. Stating the drawbacks of your own proposal demonstrates maturity and production experience.

3. Clean Code & Edge-Case Proactivity

In live-coding rounds, communicate your thinking aloud before typing. State edge cases explicitly: null or undefined inputs, extreme boundary values, concurrency races, and network timeouts. Writing modular, well-named functions with deterministic unit tests separates junior candidates from staff-level engineers.

4. Antipatterns to Avoid

Avoid reciting memorized definitions without practical context. Never dismiss non-functional requirements such as security (CSRF, injection, token rotation), observability (logging, metrics), and accessibility (ARIA, semantic standards). Always ask clarifying scope questions before writing complex implementations.

Continuous learning: Practice daily, mark completed questions as learned, and revisit difficult concepts.Explore All Interview Tracks →

Explore Related Tools

Hand-picked utilities and calculators related to this tool.

Related Tools