1. Who This Roadmap Is For
This roadmap is designed for a professional who already has working experience with PostgreSQL and wants to move beyond routine SQL development.
You may already know how to:
- Create tables.
- Write SELECT, INSERT, UPDATE, and DELETE statements.
- Use JOINs.
- Create indexes.
- Work with PostgreSQL from Java, Python, .NET, Node.js, or another backend technology.
- Deploy applications that use PostgreSQL.
- Investigate basic database issues.
The next level is different. An experienced PostgreSQL professional should understand not only how to write SQL, but also:
- Why PostgreSQL selects a particular execution plan.
- Why an index is or is not used.
- How MVCC affects updates, deletes, VACUUM, and table bloat.
- How transactions interact under concurrency.
- How locking causes production incidents.
- How to diagnose a query that suddenly becomes slow.
- How to design indexes for actual workload patterns.
- How to manage large tables.
- How replication and failover work.
- How backups are restored during a real incident.
- How PostgreSQL is monitored in production.
- How to plan upgrades with minimal risk.
- How application code affects database performance.
- How to design PostgreSQL for scalability, security, availability, and maintainability.
PostgreSQL 18 is the current major production release, and PostgreSQL 18.4 was released on May 14, 2026. PostgreSQL 19 is still in development/beta as of August 2026. PostgreSQL major versions receive five years of support, which makes version lifecycle and upgrade planning part of professional PostgreSQL administration.
What Makes This an Experienced PostgreSQL Track
Experienced PostgreSQL work is about correctness under concurrency, predictable query performance, safe schema evolution, and recoverability. Knowing SQL syntax is only the starting point; you should understand why the planner chooses a path and how transactions interact when many sessions modify data at once.
Practice reading EXPLAIN plans, choosing indexes based on actual predicates and ordering, recognizing poor cardinality estimates, and distinguishing CPU, I/O, lock, and network bottlenecks. Review isolation levels, MVCC, row locks, deadlocks, vacuum behavior, long-running transactions, and the operational impact of schema changes on large tables.
Create one database case study with realistic data volume. Start with a slow query, capture its plan, improve it, and compare the result. Add a concurrent update scenario and document the locking behavior. Plan a schema change that can be deployed safely without blocking a busy table for an unacceptable period. Include backup/restore expectations and what recovery point/recovery time the application actually needs.
Senior database interviews should go beyond “which index should I add?” Be prepared to explain why an index is not used, how you would investigate rising replication lag, what causes table bloat, how to reduce deadlock risk, and why a query can become slow after data distribution changes. Evidence from plans and metrics should drive the answer.
2. Target Skill Level
After completing this roadmap, you should be able to handle PostgreSQL from four angles:
Application Development
You should be able to design SQL and database structures that work efficiently with application code.
Database Engineering
You should understand indexing, query plans, transactions, concurrency, partitioning, maintenance, configuration, and data movement.
Production Operations
You should be able to investigate performance degradation, locks, replication lag, storage growth, failed jobs, connection exhaustion, and backup problems.
Architecture
You should be able to make decisions about:
- Schema design.
- Data types.
- Index strategy.
- Partitioning.
- Read replicas.
- Connection pooling.
- High availability.
- Disaster recovery.
- Data retention.
- Migration.
- Scaling.
3. PostgreSQL Architecture Refresher
Caution: Do not skip architecture because you already know SQL. Many production problems become easier once you understand what PostgreSQL is doing internally.
Study:
- PostgreSQL server process architecture.
- Client/server communication.
- PostgreSQL cluster.
- Database.
- Schema.
- Relation.
- Table.
- Index.
- Sequence.
- View.
- Materialized view.
- System catalogs.
- Backend processes.
- Background processes.
- Shared memory.
- Shared buffers.
- WAL.
- Checkpointer.
- Background writer.
- Autovacuum launcher.
- Autovacuum workers.
- WAL sender.
- WAL receiver.
- Replication slots.
- Temporary files.
- Tablespaces.
Understand the hierarchy:
PostgreSQL Instance
Database
Schema
Table
View
Sequence
Function
Procedure
Index
A single PostgreSQL server can contain multiple databases. Within each database, schemas provide logical namespaces.
For experienced professionals, the practical question is not simply "What is a schema?"
The useful questions are:
- Should every microservice receive its own database?
- Should multiple applications share one database?
- Should tenants use separate databases or schemas?
- How should privileges be separated?
- What happens to connection counts when databases are separated?
- How will backups and migrations be managed?
PostgreSQL's administration documentation covers server configuration, maintenance, backup, recovery, replication, and production management as distinct operational concerns.
4. PostgreSQL Data Types
An experienced engineer should select data types intentionally.
Numeric Types
Understand:
- smallint
- integer
- bigint
- numeric
- decimal
- real
- double precision
Use integer types for exact whole numbers.
Use numeric when decimal precision matters, such as monetary calculations requiring controlled decimal behavior.
Caution: Avoid storing numeric information in varchar merely because input arrives as text.
Character Types
Study:
- char
- varchar
- text
In PostgreSQL, text is commonly suitable when no application-level length restriction is required.
Length restrictions should usually represent actual business rules rather than arbitrary database conventions.
Boolean
Use:
boolean
instead of:
varchar(5)
containing values such as:
yes
no
true
false
Date and Time
Understand:
- date
- time
- timestamp
- timestamp with time zone
- interval
A working professional must understand the difference between:
timestamp
and:
timestamptz
Timezone mistakes frequently appear only after applications expand across regions.
UUID
UUID is commonly useful for distributed identifier generation.
Example:
CREATE TABLE customer (
id uuid PRIMARY KEY,
name text NOT NULL
);
Understand the trade-off between:
- Integer primary keys.
- Bigint primary keys.
- UUID primary keys.
Consider:
- Index size.
- Insert patterns.
- External exposure.
- Distributed generation.
- Storage.
- Application requirements.
JSON and JSONB
Learn:
- json
- jsonb
- JSON operators.
- JSON extraction.
- Containment.
- JSON path.
- GIN indexes.
- Expression indexes.
JSONB is useful when part of the domain is genuinely semi-structured.
Caution: Do not replace a well-designed relational schema with one enormous JSON document merely to avoid schema design.
Arrays
PostgreSQL supports arrays.
Understand:
- Array creation.
- Array operators.
- ANY.
- ALL.
- unnest().
- Array indexing.
- GIN indexing where appropriate.
Arrays are useful for some workloads but should not automatically replace normalized relationships.
Range Types
Study range types for domains involving:
- Scheduling.
- Reservations.
- Time windows.
- Numeric ranges.
Enumerated Types
ENUM can provide strongly constrained values, but schema evolution requirements should be considered before using it heavily.
Domain Types
Domains allow reusable constraints around an underlying data type.
They can be useful when the same validation rule occurs throughout the database.
5. Advanced SQL Mastery
SQL remains a major differentiator even for experienced developers.
You should be comfortable writing complex queries without turning every requirement into application-side processing.
JOINs
Master:
- INNER JOIN.
- LEFT JOIN.
- RIGHT JOIN.
- FULL JOIN.
- CROSS JOIN.
- SELF JOIN.
- LATERAL JOIN.
Understand join cardinality.
A query can become extremely expensive when developers accidentally create:
100,000 × 50,000
intermediate rows.
Always understand:
- One-to-one.
- One-to-many.
- Many-to-many relationships.
6. Aggregation
Master:
- COUNT.
- SUM.
- AVG.
- MIN.
- MAX.
- GROUP BY.
- HAVING.
- FILTER.
Example:
SELECT department_id,
COUNT(*) AS employee_count,
AVG(salary) AS average_salary
FROM employee
GROUP BY department_id;
Understand the difference between:
WHERE
and:
HAVING
WHERE filters rows before grouping.
HAVING filters groups after aggregation.
7. Window Functions
Window functions are mandatory knowledge for experienced SQL developers.
Study:
- ROW_NUMBER().
- RANK().
- DENSE_RANK().
- LAG().
- LEAD().
- FIRST_VALUE().
- LAST_VALUE().
- SUM() OVER.
- AVG() OVER.
- PARTITION BY.
- ORDER BY inside windows.
- Window frames.
Example:
SELECT employee_id,
department_id,
salary,
RANK() OVER (
PARTITION BY department_id
ORDER BY salary DESC
) AS salary_rank
FROM employee;
Practical uses include:
- Top N employees per department.
- Running totals.
- Previous transaction comparison.
- Customer activity ranking.
- Duplicate detection.
- Latest row per entity.
- Trend analysis.
8. Common Table Expressions
Study:
- WITH.
- Multiple CTEs.
- Recursive CTEs.
- Data-modifying CTEs where appropriate.
- MATERIALIZED.
- NOT MATERIALIZED.
Example:
WITH department_salary AS (
SELECT department_id,
AVG(salary) AS avg_salary
FROM employee
GROUP BY department_id
)
SELECT *
FROM department_salary
WHERE avg_salary > 80000;
Caution: Do not use CTEs simply because they make SQL look sophisticated.
Use them when they improve:
- Query decomposition.
- Readability.
- Recursive processing.
- Reusability within a statement.
9. Recursive Queries
Learn recursive CTEs for hierarchical data.
Typical cases:
- Organizational hierarchy.
- Category tree.
- Folder structure.
- Bill of materials.
- Dependency graph.
Understand termination conditions carefully. Incorrect recursive logic can produce excessive processing.
10. Subqueries
Master:
- Scalar subqueries.
- Correlated subqueries.
- EXISTS.
- NOT EXISTS.
- IN.
- NOT IN.
Pay special attention to NULL behavior with NOT IN.
In many anti-join situations:
NOT EXISTS
provides clearer semantics.
11. Set Operations
Understand:
- UNION.
- UNION ALL.
- INTERSECT.
- EXCEPT.
Know that UNION performs duplicate elimination while UNION ALL does not.
When duplicate elimination is unnecessary, UNION ALL avoids that additional work.
12. Conditional SQL
Master:
- CASE.
- COALESCE.
- NULLIF.
- GREATEST.
- LEAST.
Example:
SELECT customer_id,
COALESCE(phone_number, 'Not Provided')
FROM customer;
13. NULL Handling
Experienced developers must understand SQL's three-valued logic.
Incorrect:
WHERE deleted_at = NULL
Correct:
WHERE deleted_at IS NULL
Study how NULL affects:
- Equality.
- Aggregates.
- Sorting.
- Constraints.
- Joins.
- NOT IN.
- Unique constraints.
- Application mapping.
14. INSERT, UPDATE and DELETE at Scale
Move beyond basic DML.
Study:
- INSERT ... SELECT.
- INSERT ... RETURNING.
- UPDATE ... FROM.
- DELETE ... USING.
- UPSERT.
- ON CONFLICT.
- Bulk loading.
- COPY.
Example:
INSERT INTO customer(email, name)
VALUES ('john@example.com', 'John')
ON CONFLICT (email)
DO UPDATE
SET name = EXCLUDED.name;
PostgreSQL's COPY command can transfer data between PostgreSQL tables and files and is a core tool for bulk data movement.
15. Database Schema Design
Experienced PostgreSQL work starts with good data modeling.
Study:
- Entities.
- Relationships.
- Primary keys.
- Foreign keys.
- Natural keys.
- Surrogate keys.
- Candidate keys.
- Unique constraints.
- Check constraints.
- NOT NULL constraints.
- Referential integrity.
16. Normalization
Understand:
- First Normal Form.
- Second Normal Form.
- Third Normal Form.
- BCNF conceptually.
Caution: Do not normalize mechanically.
Ask:
- What data anomalies are possible?
- How frequently is the relationship queried?
- What is the write pattern?
- Is controlled denormalization justified?
17. Constraints
Use database constraints to protect data integrity.
Example:
CREATE TABLE product (
product_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name text NOT NULL,
price numeric(12,2) CHECK (price >= 0),
sku text UNIQUE
);
Caution: Do not rely exclusively on application validation.
Application bugs, scripts, ETL processes, administrative commands, and other integrations may bypass application validation.
18. Identity Columns and Sequences
Understand:
- GENERATED ALWAYS AS IDENTITY.
- GENERATED BY DEFAULT AS IDENTITY.
- Sequences.
- nextval().
- currval().
- Sequence caching.
- Sequence gaps.
A sequence does not guarantee gap-free numbering.
Caution: Do not design financial invoice sequencing requirements without understanding this behavior.
19. Indexing from an Experienced Engineer's Perspective
Knowing:
CREATE INDEX
is not enough.
You must know why, when, and what type of index to create.
PostgreSQL provides extensive indexing capabilities, and index selection should correspond to query predicates, sort requirements, data distribution, and operator behavior.
B-tree Index
Best suited to many common operations involving:
- Equality.
- Range conditions.
- Ordering.
Example:
CREATE INDEX idx_orders_customer_id
ON orders(customer_id);
Multicolumn Index
Example:
CREATE INDEX idx_orders_customer_status
ON orders(customer_id, status);
Column order matters.
For a query:
WHERE customer_id = ?
AND status = ?
the above index may work well.
But never create multicolumn indexes based only on the order columns appear in source code.
Analyze actual predicates and workload.
20. Partial Indexes
Partial indexes index only qualifying rows.
Example:
CREATE INDEX idx_pending_orders
ON orders(created_at)
WHERE status = 'PENDING';
This can be useful when a small subset of rows is queried frequently.
21. Expression Indexes
Example:
CREATE INDEX idx_customer_lower_email
ON customer(lower(email));
This can support queries such as:
WHERE lower(email) = lower(?)
PostgreSQL documentation notes that newly created expression indexes require suitable statistics, either through ANALYZE or subsequent automatic analysis, for effective planner decisions.
22. Covering Indexes
Study INCLUDE.
Example:
CREATE INDEX idx_orders_customer_cover
ON orders(customer_id)
INCLUDE (status, total_amount);
Understand when index-only scans are possible rather than assuming INCLUDE automatically makes every query faster.
23. Specialized Index Types
Learn the use cases for:
B-tree
General equality, range, sorting.
Hash
Equality-oriented workloads.
GIN
Commonly useful with:
- JSONB.
- Arrays.
- Full-text search.
GiST
Useful for several specialized data types and search patterns.
SP-GiST
Useful for certain partitioned search structures.
BRIN
Potentially useful for very large tables where values correlate with physical row order, such as time-series data.
Caution: Do not attempt to memorize only definitions. Build sample workloads and compare execution plans.
24. Index Selectivity
Suppose a table contains ten million users but only:
active = true
active = false
An index on a low-cardinality boolean column may not automatically improve every query.
Understand:
- Cardinality.
- Selectivity.
- Data distribution.
- Query frequency.
- Returned row percentage.
25. Duplicate and Unused Indexes
Too many indexes create costs:
- Additional storage.
- Slower INSERT.
- Slower UPDATE.
- Slower DELETE.
- Additional VACUUM work.
- Additional cache consumption.
An experienced engineer evaluates indexes as workload structures, not decorations.
26. Query Execution Plans
One of the strongest skills for a PostgreSQL professional is reading execution plans.
Master:
EXPLAIN
and:
EXPLAIN ANALYZE
Also learn:
EXPLAIN (ANALYZE, BUFFERS)
Example:
EXPLAIN (ANALYZE, BUFFERS)
SELECT *
FROM orders
WHERE customer_id = 1001;
Read the plan from the inner operations outward.
Study:
- Sequential Scan.
- Index Scan.
- Index Only Scan.
- Bitmap Index Scan.
- Bitmap Heap Scan.
- Nested Loop.
- Hash Join.
- Merge Join.
- Sort.
- Hash.
- Aggregate.
- Parallel operations.
- Planning time.
- Execution time.
- Estimated rows.
- Actual rows.
- Loops.
- Buffer usage.
A major warning sign is a large difference between:
estimated rows
and:
actual rows
That may indicate:
- Poor statistics.
- Correlated columns.
- Data skew.
- Difficult predicates.
- Planner estimation limitations.
27. Why PostgreSQL Ignores an Index
Possible reasons include:
- Query returns a large part of the table.
- Sequential scan is estimated to be cheaper.
- Function applied to indexed column.
- Implicit or explicit type behavior affects the predicate.
- Statistics are stale.
- Index column order does not match the workload.
- Partial index predicate does not match.
- Table is small.
- Data distribution makes the index unattractive.
Caution: Do not "solve" this by disabling sequential scans in production.
Investigate why the planner selected the plan.
28. PostgreSQL Query Planner
Study:
- Planner cost model.
- Row estimates.
- Table statistics.
- Column statistics.
- Histograms.
- Most common values.
- Distinct value estimates.
- Extended statistics.
- Join planning.
- Join order.
- Cost parameters.
After significant changes in data distribution, ANALYZE helps provide the planner with current statistics; stale or missing statistics can lead to poor plan choices.
29. Statistics
Understand:
ANALYZE table_name;
Investigate statistics using PostgreSQL system catalogs and views rather than blindly running maintenance commands.
Learn:
- default_statistics_target.
- Per-column statistics targets.
- Extended statistics.
Extended statistics can help when columns are correlated and independent-column estimates produce inaccurate cardinality estimates.
30. Transactions
Master:
- BEGIN.
- COMMIT.
- ROLLBACK.
- SAVEPOINT.
- ROLLBACK TO SAVEPOINT.
Example:
BEGIN;
UPDATE account
SET balance = balance - 500
WHERE account_id = 101;
UPDATE account
SET balance = balance + 500
WHERE account_id = 202;
COMMIT;
Transactions provide atomicity and visibility guarantees across related operations. PostgreSQL records transactional changes so completed transactions can survive crashes according to its durability mechanisms.
31. Transaction Isolation
Understand:
- Read Committed.
- Repeatable Read.
- Serializable.
Caution: Do not memorize isolation levels only for interviews.
Understand practical problems involving:
- Lost update.
- Non-repeatable reads.
- Phantom-like behavior.
- Write conflicts.
- Serialization failures.
PostgreSQL implements transaction isolation using MVCC and supports Serializable isolation. Applications using Repeatable Read or Serializable must be prepared for transactions that can require retries after serialization-related failures.
32. MVCC
MVCC stands for Multi-Version Concurrency Control.
This is central to PostgreSQL.
When rows are updated, PostgreSQL works with row versions rather than simply overwriting every row in place as a conceptual beginner model might suggest.
Understand:
- Tuple versions.
- xmin.
- xmax.
- Snapshots.
- Visibility.
- Dead tuples.
- Transaction IDs.
- Long-running transactions.
MVCC allows readers and writers to operate with relatively low interference; PostgreSQL's documentation describes how reads normally do not conflict with ordinary writes under this model.
33. VACUUM
Learn:
- VACUUM.
- VACUUM ANALYZE.
- VACUUM FULL.
- Autovacuum.
VACUUM is not optional housekeeping that can be ignored indefinitely.
PostgreSQL recommends regular vacuuming and includes autovacuum to automate routine maintenance and removal/reuse of space associated with dead row versions.
Understand:
- Dead tuples.
- Table bloat.
- Index bloat.
- Transaction ID wraparound.
- Autovacuum thresholds.
- Scale factors.
- Vacuum cost settings.
- Long-running transactions preventing cleanup.
34. VACUUM vs VACUUM FULL
Caution: Do not treat them as equivalent.
VACUUM performs routine cleanup operations.
VACUUM FULL rewrites a table and requires significantly stronger locking.
It should not become the default answer whenever a table grows.
Investigate the cause first.
35. Autovacuum Tuning
For high-write tables, default autovacuum behavior may not fit every workload.
Study table-level settings such as:
- autovacuum_vacuum_scale_factor.
- autovacuum_vacuum_threshold.
- autovacuum_analyze_scale_factor.
- autovacuum_analyze_threshold.
Large tables deserve special attention because percentage-based thresholds can translate into large numbers of changed rows.
36. Locking
Learn:
- Table-level locks.
- Row-level locks.
- Advisory locks.
- Deadlocks.
- Lock waits.
Study statements such as:
SELECT ...
FOR UPDATE;
and:
SELECT ...
FOR NO KEY UPDATE;
PostgreSQL provides explicit lock modes in addition to the locks automatically acquired by SQL operations.
37. Deadlocks
Example:
Transaction A locks row 1 and waits for row 2.
Transaction B locks row 2 and waits for row 1.
PostgreSQL detects the deadlock and aborts one transaction.
Prevention strategies include:
- Access shared resources in consistent order.
- Keep transactions short.
- Avoid user interaction inside database transactions.
- Update only required rows.
- Retry suitable failed transactions from the application.
38. Long-Running Transactions
Long transactions can create several operational problems:
- Hold locks.
- Delay cleanup of old row versions.
- Increase storage pressure.
- Make maintenance harder.
- Increase failure impact.
Monitor them proactively.
39. Functions
Learn PostgreSQL functions using:
- SQL.
- PL/pgSQL.
Understand:
- Parameters.
- Return values.
- RETURN QUERY.
- Set-returning functions.
- Exception handling.
- Function volatility.
- SECURITY DEFINER.
- SECURITY INVOKER considerations.
Caution: Do not move all business logic into database functions without an architectural reason.
40. Procedures
Understand the difference between:
- Functions.
- Procedures.
Procedures support different execution semantics and can be useful for certain server-side workflows.
Evaluate maintainability before introducing large procedural layers.
41. Triggers
Study:
- BEFORE trigger.
- AFTER trigger.
- INSTEAD OF trigger.
- Row-level trigger.
- Statement-level trigger.
Useful scenarios include:
- Auditing.
- Derived data.
- Controlled synchronization.
- Certain integrity rules.
Common problem:
Developers forget a trigger exists and spend hours investigating "mysterious" additional database activity.
Keep trigger behavior documented and observable.
42. Views
Use views to:
- Simplify complex queries.
- Encapsulate database interfaces.
- Restrict exposure of selected data.
- Provide logical abstractions.
Understand that a normal view stores a query definition rather than materialized query results.
43. Materialized Views
Materialized views physically store query results and can be useful for expensive read-heavy calculations.
Study:
REFRESH MATERIALIZED VIEW
and:
REFRESH MATERIALIZED VIEW CONCURRENTLY
Concurrent refresh has specific requirements, including an appropriate UNIQUE index, and permits reads to continue during refresh.
44. Partitioning
Master declarative partitioning.
Study:
- Range partitioning.
- List partitioning.
- Hash partitioning.
- Partition pruning.
- Partition maintenance.
- Local partition indexes.
- Data retention workflows.
Example:
CREATE TABLE orders (
order_id bigint,
created_at date NOT NULL,
total_amount numeric(12,2)
) PARTITION BY RANGE (created_at);
Partitioning can improve performance and maintenance for suitable large-table workloads, particularly when queries touch only a small subset of partitions. It is not automatically beneficial for every large table.
45. When to Partition
Consider partitioning when:
- Tables are genuinely large.
- Queries frequently filter on the partition key.
- Old data must be removed efficiently.
- Data naturally divides by time, tenant, region, or another suitable dimension.
- Operational management becomes easier through partition boundaries.
Caution: Do not partition a small table simply because the application is expected to become popular someday.
46. JSONB for Production Applications
Example:
CREATE TABLE event (
event_id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
event_data jsonb NOT NULL
);
Query:
SELECT *
FROM event
WHERE event_data->>'type' = 'LOGIN';
Possible expression index:
CREATE INDEX idx_event_type
ON event((event_data->>'type'));
Learn how to decide whether a field should remain inside JSONB or become a proper relational column.
Frequently filtered, constrained, joined, or business-critical attributes often deserve explicit schema representation.
47. Full-Text Search
Learn PostgreSQL full-text concepts:
- tsvector.
- tsquery.
- to_tsvector().
- to_tsquery().
- plainto_tsquery().
- Ranking.
- GIN indexing.
Understand when PostgreSQL search capabilities are enough and when an external search system may be justified.
48. Database Security
Experienced professionals should understand:
- Roles.
- Users.
- Privileges.
- Role membership.
- GRANT.
- REVOKE.
- Schema privileges.
- Table privileges.
- Sequence privileges.
- Function privileges.
- Default privileges.
- Row-Level Security.
- TLS.
- Authentication configuration.
- pg_hba.conf.
PostgreSQL includes predefined roles for specific administrative capabilities, allowing privileges to be delegated more narrowly than simply granting broad superuser access.
49. Principle of Least Privilege
An application generally should not connect as:
postgres
or another superuser.
Instead, separate roles by responsibility.
For example:
application_runtime
migration_user
readonly_reporting
monitoring_user
database_admin
Restrict each role to what it needs.
50. Row-Level Security
RLS can enforce access rules at row level.
It is relevant to applications such as:
- Multi-tenant systems.
- Department-level access.
- User-owned records.
- Sensitive domain separation.
Caution: Do not implement RLS without understanding interactions with:
- Roles.
- Ownership.
- Policies.
- Administrative users.
- Backup and restore.
- Application connection models.
51. Connection Management
Every PostgreSQL connection consumes resources.
Applications should manage connections deliberately.
Understand:
- Connection pooling.
- Maximum connections.
- Application pool sizing.
- Idle connections.
- Idle transactions.
- Connection leaks.
- Pool timeout.
- Statement timeout.
- Transaction timeout behavior where applicable.
Learn tools such as PgBouncer when connection multiplexing is required.
Caution: Do not set:
max_connections = 5000
merely because an application reports connection errors.
Find the actual cause.
52. PostgreSQL Memory Configuration
Understand settings including:
- shared_buffers.
- work_mem.
- maintenance_work_mem.
- effective_cache_size.
Caution: Do not copy configuration values from a blog without considering:
- RAM.
- Concurrent sessions.
- Query workload.
- Operating system.
- Storage.
- PostgreSQL version.
A key experienced-level point:
work_mem
can potentially be consumed by multiple execution operations and multiple concurrent sessions.
Therefore:
100 MB work_mem × 500 connections
does not mean PostgreSQL has reserved only 100 MB.
53. WAL
Write-Ahead Logging is fundamental to PostgreSQL durability and replication.
Understand:
- WAL records.
- WAL segments.
- Checkpoints.
- Crash recovery.
- Archiving.
- Replication.
- WAL retention.
- Replication slots.
You do not need to become a PostgreSQL source-code developer, but an experienced PostgreSQL engineer should know how WAL affects production systems.
54. Checkpoints
Understand:
- What a checkpoint does.
- Why excessive checkpoint activity can affect I/O.
- Relationship between WAL generation and checkpoint behavior.
- Relevant configuration.
- How to inspect checkpoint-related logging and statistics.
PostgreSQL exposes checkpoint and related operational information through logging and statistics facilities.
55. Monitoring PostgreSQL
Master system views including:
- pg_stat_activity.
- pg_stat_database.
- pg_stat_user_tables.
- pg_stat_user_indexes.
- pg_stat_replication.
- pg_stat_wal.
- pg_stat_io.
- pg_locks.
- pg_stat_progress_vacuum.
- pg_stat_progress_create_index.
PostgreSQL's cumulative statistics system exposes database, table, index, WAL, I/O, replication, maintenance, and session activity metrics.
56. pg_stat_statements
This is one of the most useful PostgreSQL performance extensions.
It tracks planning and execution statistics for SQL statements executed by the server.
Use it to identify:
- Most frequently executed queries.
- Highest total execution time.
- Expensive average execution time.
- High I/O queries.
- Application-generated SQL patterns.
Caution: Do not optimize one query simply because someone saw it taking two seconds once.
Prioritize using workload impact.
57. Production Performance Investigation Workflow
Suppose the application team reports:
Note: API response time increased from 300 ms to 5 seconds.
Use a structured approach.
Step 1: Determine Scope
Check:
- One endpoint or all endpoints?
- One database or all databases?
- Recent release?
- Recent schema change?
- Traffic spike?
- Batch job running?
Step 2: Check Database Activity
Inspect:
pg_stat_activity
Look for:
- Active queries.
- Long-running queries.
- Idle in transaction sessions.
- Waiting sessions.
Step 3: Check Locks
Investigate:
pg_locks
Determine whether blocked sessions exist.
Step 4: Identify Expensive SQL
Use:
pg_stat_statements
Step 5: Examine Execution Plan
Use:
EXPLAIN (ANALYZE, BUFFERS)
in a safe environment or with appropriate production caution.
Step 6: Compare Estimates and Actual Results
Check:
- Estimated rows.
- Actual rows.
- Scan types.
- Join types.
- Sorts.
- Temporary I/O.
- Buffer activity.
Step 7: Investigate Statistics
Check whether data changed significantly.
Step 8: Investigate Infrastructure
Check:
- CPU.
- Memory.
- Disk latency.
- IOPS.
- Storage capacity.
- Network.
- Connection count.
Step 9: Check Maintenance
Look for:
- VACUUM.
- Autovacuum.
- ANALYZE.
- Index creation.
- Backup.
- Large batch processing.
Step 10: Fix the Root Cause
Possible solutions may involve:
- Query rewriting.
- Index changes.
- Updated statistics.
- Application batching.
- Lock reduction.
- Connection-pool correction.
- Partitioning.
- Configuration adjustment.
- Infrastructure scaling.
58. Backup
Learn logical backups:
- pg_dump.
- pg_dumpall.
- pg_restore.
Understand formats:
- Plain SQL.
- Custom.
- Directory.
- Tar.
PostgreSQL's pg_dump supports database-level logical backup, while production recovery architecture also includes physical backup and continuous archiving approaches.
59. Restore Testing
A backup that has never been restored successfully is an unverified backup strategy.
Practice:
- Restoring to another server.
- Restoring individual databases.
- Restoring selected objects.
- Recovering roles.
- Validating row counts.
- Validating application startup after restore.
60. Point-in-Time Recovery
Study:
- Base backup.
- WAL archiving.
- Restore process.
- Recovery target.
- Recovery timeline.
PITR allows recovery toward a particular point in the WAL history rather than only restoring the last logical dump. PostgreSQL documents continuous archiving and PITR as part of its backup and recovery architecture.
61. Recovery Objectives
Understand:
RPO
Recovery Point Objective.
How much data loss can the business tolerate?
RTO
Recovery Time Objective.
How long can the system remain unavailable?
Architecture should follow business requirements instead of simply saying:
Note: We take a backup every night.
62. Physical Replication
Learn streaming replication.
Understand:
Primary
|
| WAL
v
Standby
Study:
- WAL sender.
- WAL receiver.
- Standby.
- Replication lag.
- Synchronous replication.
- Asynchronous replication.
- Hot standby.
- Promotion.
63. Synchronous vs Asynchronous Replication
Asynchronous
Advantages:
- Lower commit latency.
Trade-off:
- Recent transactions may not yet have reached the standby when a primary fails.
Synchronous
Advantages:
- Stronger durability guarantees across configured synchronous nodes.
Trade-off:
- Commit latency and availability characteristics change because acknowledgements are required according to configuration.
The correct choice depends on business requirements.
64. Replication Slots
Understand:
- Physical replication slots.
- Logical replication slots.
- WAL retention.
A forgotten or inactive replication slot can cause WAL accumulation.
This can eventually consume significant storage.
Monitoring replication slots is therefore an operational requirement.
65. Logical Replication
Study:
- Publication.
- Subscription.
- Replicated tables.
- Initial synchronization.
- Replication conflicts.
- Schema considerations.
Logical replication can be useful for:
- Selective table replication.
- Migration.
- Upgrade strategies.
- Data distribution.
- Integration architectures.
66. High Availability
A complete HA solution involves more than adding a replica.
Understand:
- Primary failure detection.
- Standby promotion.
- Client routing.
- Failover.
- Fencing/split-brain prevention.
- Connection handling.
- Monitoring.
- Recovery after failover.
Common ecosystem technologies may include:
- Patroni.
- etcd/Consul depending on architecture.
- HAProxy.
- PgBouncer.
- Cloud-managed failover services.
Learn concepts first. Tools change.
67. Read Scaling
Read replicas can move suitable read workloads away from the primary.
But understand:
- Replication lag.
- Read-after-write consistency.
- Stale reads.
- Transaction behavior.
- Application routing.
A request immediately following a write may not see the latest data on an asynchronous replica.
Applications must account for that.
68. Horizontal vs Vertical Scaling
Vertical Scaling
Increase:
- CPU.
- RAM.
- Storage performance.
Often the simplest first scaling step.
Horizontal Scaling
Distribute workload across:
- Read replicas.
- Partitioned architectures.
- Sharding systems.
- Multiple database instances.
Horizontal database scaling introduces substantial operational complexity.
Caution: Do not shard before proving that simpler approaches cannot meet requirements.
69. Sharding Concepts
Understand:
- Shard key.
- Routing.
- Cross-shard queries.
- Distributed transactions.
- Rebalancing.
- Hot shards.
- Global uniqueness.
- Operational complexity.
PostgreSQL can participate in sharded architectures through application-level designs and ecosystem technologies, but sharding should be driven by concrete scaling requirements.
70. Foreign Data Wrappers
Learn the concept of Foreign Data Wrappers.
postgres_fdw can allow PostgreSQL to access tables in another PostgreSQL database.
Understand:
- Foreign servers.
- User mappings.
- Foreign tables.
- Pushdown behavior.
- Network costs.
- Transaction limitations and architectural consequences.
Caution: Do not use FDWs to hide poor service boundaries without considering failure modes.
71. Extensions
Understand PostgreSQL's extension ecosystem.
Examples worth knowing conceptually include:
- pg_stat_statements.
- pg_trgm.
- postgres_fdw.
- uuid-related functionality depending on version/environment.
- PostGIS when geospatial workloads are required.
Before installing an extension in production, evaluate:
- Compatibility.
- Upgrade support.
- Security.
- Cloud support.
- Operational ownership.
72. Database Migration Management
Production systems need controlled schema migrations.
Learn tools and approaches such as:
- Flyway.
- Liquibase.
- Framework migration systems.
- Versioned SQL migrations.
Understand:
- Forward migration.
- Rollback strategy.
- Backward compatibility.
- Expand-and-contract migrations.
73. Zero-Downtime-Oriented Schema Changes
Suppose you need to change an application column.
A safer process may be:
- Add the new schema component.
- Make application versions compatible with old and new structures.
- Backfill data gradually.
- Switch reads/writes.
- Validate production behavior.
- Remove obsolete structures later.
Caution: Avoid assuming every:
ALTER TABLE
is operationally harmless.
Large-table DDL should be reviewed for:
- Locking.
- Rewrites.
- WAL generation.
- Storage.
- Replica impact.
- Application compatibility.
Some table-rewriting DDL has special MVCC implications, which is another reason production schema changes require planning rather than blind execution.
74. Major PostgreSQL Upgrades
Understand three major upgrade approaches:
- Dump and restore.
- pg_upgrade.
- Logical replication.
PostgreSQL's current documentation explicitly covers these approaches for moving clusters to newer major versions.
Before upgrading:
- Read release notes.
- Check extension compatibility.
- Test application queries.
- Test drivers.
- Benchmark critical workloads.
- Test backups.
- Test rollback/fallback strategy.
- Validate monitoring.
- Run migration rehearsals.
75. PostgreSQL 18 Awareness
An experienced professional should know the current major version rather than learning only syntax from PostgreSQL 10-era tutorials.
PostgreSQL 18 was released on September 25, 2025 and introduced multiple enhancements, including a new asynchronous I/O subsystem along with other performance, SQL, monitoring, replication, and operational improvements.
Caution: Do not memorize release notes for interviews.
Instead:
- Know your production version.
- Know what versions are supported.
- Understand changes affecting your workload.
- Read release notes before upgrades.
- Maintain a version upgrade strategy.
76. Application Integration
Experienced PostgreSQL developers should understand how application architecture affects the database.
Study:
- JDBC or equivalent drivers.
- Connection pools.
- Prepared statements.
- Parameterized SQL.
- Transaction boundaries.
- Batch operations.
- Fetch size.
- ORM-generated SQL.
- Pagination.
- Retry behavior.
- Timeout configuration.
77. ORM Problems
Hibernate, JPA, Entity Framework, Sequelize, Django ORM, SQLAlchemy, and similar tools can improve productivity.
They can also generate inefficient SQL.
Understand problems such as:
- N+1 queries.
- Excessive eager loading.
- Excessive lazy loading.
- Huge joins.
- Unbounded result sets.
- One database call per row.
- Incorrect transaction boundaries.
Experienced backend developers inspect the SQL generated by the ORM.
78. Pagination
Caution: Avoid blindly using large OFFSET values.
Example:
SELECT *
FROM orders
ORDER BY order_id
LIMIT 50
OFFSET 5000000;
As offsets become large, the database may still need to process many rows before returning the requested page.
For suitable workloads, learn keyset pagination.
Example:
SELECT *
FROM orders
WHERE order_id > 5000000
ORDER BY order_id
LIMIT 50;
79. Batch Operations
Bad application pattern:
INSERT row 1
INSERT row 2
INSERT row 3
...
INSERT row 100000
using separate round trips.
Investigate:
- Batched statements.
- Multi-row INSERT.
- COPY.
Choose based on workload and application requirements.
80. Prepared Statements and SQL Injection
Never concatenate untrusted user input directly into SQL.
Use parameterized statements.
Bad conceptual pattern:
"SELECT * FROM users WHERE email = '" + userInput + "'"
Use driver-supported parameters instead.
Security must be addressed at both application and database layers.
81. Timeouts
Production systems should have deliberate timeout policies.
Study:
- statement_timeout.
- lock_timeout.
- idle_in_transaction_session_timeout.
- Application-side connection timeout.
- Pool acquisition timeout.
- HTTP/request timeout interaction.
Without coordinated timeout policies, one slow database operation can tie up application threads and connections.
82. Logging
Learn:
- Slow query logging.
- Connection logging.
- Disconnection logging.
- Lock wait logging.
- Checkpoint logging.
- Error severity.
- Log rotation.
- Log analysis.
Be cautious when logging SQL because queries can contain sensitive values. PostgreSQL documentation explicitly warns that logged statements may expose sensitive data.
83. Database Observability
For production, monitor at least:
Workload
- Transactions per second.
- Query latency.
- Query volume.
Connections
- Active.
- Idle.
- Waiting.
- Idle in transaction.
Storage
- Database size.
- Table growth.
- WAL generation.
- Disk utilization.
Performance
- Cache behavior.
- I/O.
- Temporary file activity.
- Slow queries.
Maintenance
- Autovacuum.
- Analyze.
- Dead tuples.
Replication
- Replica status.
- Lag.
- Slot status.
Reliability
- Errors.
- Restarts.
- Failed backups.
84. Common Production Incident: Connection Exhaustion
Symptoms:
- New application connections fail.
- Requests time out.
- Database reaches connection limit.
Possible causes:
- Connection leak.
- Oversized application pools.
- Too many application replicas.
- Long-running queries.
- Idle transactions.
- Traffic increase.
Bad fix:
Increase max_connections indefinitely.
Better approach:
- Identify connection owners.
- Fix leaks.
- Tune pools.
- Introduce pooling infrastructure if required.
- Reduce transaction duration.
- Scale architecture appropriately.
85. Common Production Incident: Sudden Slow Query
Investigate:
- Was query plan changed?
- Did data volume change?
- Did data distribution change?
- Are statistics stale?
- Did an index disappear?
- Is a lock involved?
- Is autovacuum behind?
- Is storage slow?
- Is cache cold?
- Did application SQL change?
- Is parameter behavior relevant?
- Did deployment change configuration?
Use evidence before changing database parameters.
86. Common Production Incident: Database Storage Growing
Check:
- Table growth.
- Index growth.
- Dead tuples.
- WAL retention.
- Replication slots.
- Temporary data.
- Old backups.
- Log files.
- Failed archiving.
- Large unexpected imports.
"Database is large" and "database is bloated" are not the same diagnosis.
87. Common Production Incident: Blocking
Investigate:
- Blocked session.
- Blocking session.
- Query.
- Transaction start time.
- Application service.
- Lock type.
Then determine whether to:
- Wait.
- Cancel query.
- Terminate session.
- Fix transaction logic.
- Add appropriate indexing.
- Change deployment procedure.
Killing sessions without understanding the blocking chain can create another incident.
88. Common Production Incident: Replica Lag
Possible causes include:
- Heavy WAL generation.
- Network limitations.
- Slow replica storage.
- Expensive read queries on standby.
- Resource saturation.
- Configuration.
- Replay bottlenecks.
Measure lag rather than assuming replication is "working" simply because the replica is connected.
PostgreSQL exposes replication information through views such as pg_stat_replication and pg_stat_wal_receiver.
89. Database Design for Microservices
Possible patterns include:
Database per Service
Provides stronger service ownership boundaries.
Shared PostgreSQL Instance, Separate Databases
Can reduce infrastructure count while preserving database separation.
Shared Database
Sometimes appropriate but increases coupling.
The correct architecture depends on:
- Team structure.
- Service ownership.
- Transaction requirements.
- Operational maturity.
- Scale.
- Compliance.
Caution: Avoid choosing a pattern only because it is fashionable.
90. Multi-Tenant Architecture
Common approaches include:
- Shared tables with tenant_id.
- Schema per tenant.
- Database per tenant.
Evaluate:
- Tenant count.
- Isolation.
- Security.
- Backup requirements.
- Upgrade complexity.
- Cost.
- Operational automation.
- Query patterns.
There is no universally correct model.
91. PostgreSQL in Cloud Environments
Learn PostgreSQL concepts before becoming dependent on one cloud console.
Then understand managed services such as:
- Amazon RDS for PostgreSQL.
- Amazon Aurora PostgreSQL-compatible offerings.
- Azure Database for PostgreSQL.
- Google Cloud SQL for PostgreSQL.
- Other managed PostgreSQL platforms.
Study:
- Automated backups.
- Failover.
- Read replicas.
- Parameter management.
- Maintenance windows.
- Storage autoscaling.
- Monitoring.
- Encryption.
- Private networking.
- Version upgrades.
Managed PostgreSQL reduces some operational work but does not eliminate database engineering.
Bad SQL remains bad SQL in the cloud.
92. Containers and PostgreSQL
Know how to run PostgreSQL with Docker for:
- Development.
- Integration testing.
- CI environments.
Understand:
- Persistent volumes.
- Environment variables.
- Initialization scripts.
- Networking.
- Backups.
- Container lifecycle.
Running production databases in orchestration platforms requires additional storage, scheduling, failover, and operational expertise.
93. CI/CD for Database Changes
Include database changes in software delivery discipline.
A good migration pipeline can include:
Migration validation
↓
Automated test
↓
Compatibility check
↓
Staging deployment
↓
Production migration
↓
Verification
Never treat production database SQL as an undocumented manual side task.
94. Automation Skills
Experienced PostgreSQL engineers benefit from:
- Bash.
- Python.
- SQL scripting.
- Infrastructure as Code.
- CI/CD.
- Monitoring automation.
Automate repetitive operations such as:
- Health checks.
- Backup verification.
- Database provisioning.
- User provisioning.
- Reporting.
- Capacity checks.
- Migration validation.
95. Linux Knowledge
For self-managed PostgreSQL, learn:
- File systems.
- Memory.
- CPU.
- I/O.
- Processes.
- Permissions.
- Networking.
- systemd.
- Disk monitoring.
- Log management.
Database performance cannot always be diagnosed from SQL alone.
96. Networking Knowledge
Understand:
- Host.
- Port.
- DNS.
- TCP.
- Firewall.
- TLS.
- Connection latency.
- Load balancers.
- Private networking.
A connection problem is not automatically a PostgreSQL problem.
97. PostgreSQL Internals to Learn
An experienced professional should gradually understand:
- Heap storage.
- Pages.
- Tuples.
- MVCC metadata.
- TOAST.
- Visibility map.
- Free space map.
- WAL.
- Checkpoints.
- Buffer cache.
- Background writer.
- Query parsing.
- Planning.
- Execution.
- Transaction IDs.
You do not need source-code-level knowledge for most application roles, but these concepts greatly improve troubleshooting.
98. TOAST
TOAST helps PostgreSQL manage large column values.
Study:
- Large text values.
- JSONB.
- Compression.
- Out-of-line storage.
This becomes relevant when investigating storage size and wide-table behavior.
99. Temporary Files
Large sorts, hashes, or other operations can spill from memory to disk.
Investigate temporary-file generation when queries unexpectedly become I/O intensive.
Caution: Do not respond by blindly setting very large work_mem globally.
100. Parallel Query
Understand:
- Parallel sequential scan.
- Parallel index operations where supported.
- Gather.
- Gather Merge.
- Parallel workers.
Parallelism can help analytical workloads but has resource costs.
Caution: Do not judge a query merely by whether its plan contains parallel workers.
101. Performance Tuning Order
Use this general sequence.
First: Fix SQL
Check query logic.
Second: Fix Data Access
Caution: Avoid unnecessary rows and columns.
Third: Evaluate Indexes
Create indexes supported by workload evidence.
Fourth: Verify Statistics
Make sure planner estimates are reasonable.
Fifth: Investigate Application Behavior
Connection pools, batching, ORM behavior, and transactions matter.
Sixth: Investigate Database Configuration
Tune only when evidence supports it.
Seventh: Investigate Infrastructure
CPU, memory, storage, and network.
Eighth: Consider Architectural Change
Partitioning, replicas, caching, or sharding should come after simpler issues are understood.
102. Skills Expected from a Senior PostgreSQL Developer
You should be able to:
- Write complex SQL.
- Optimize queries.
- Read EXPLAIN ANALYZE.
- Design effective indexes.
- Design schemas.
- Handle transactions correctly.
- Understand concurrency.
- Investigate deadlocks.
- Work with JSONB.
- Implement partitioning where appropriate.
- Design migrations.
- Review ORM-generated SQL.
- Troubleshoot production issues.
- Monitor database health.
- Communicate database risks to application teams.
103. Skills Expected from a PostgreSQL DBA / Database Engineer
Add deeper knowledge of:
- Installation.
- Configuration.
- Backup.
- Recovery.
- PITR.
- Replication.
- HA.
- Monitoring.
- Capacity planning.
- Security.
- Vacuum tuning.
- Connection management.
- Upgrade planning.
- OS performance.
- Automation.
- Disaster recovery.
104. Skills Expected from a PostgreSQL Performance Engineer
Focus deeply on:
- Query planner.
- Statistics.
- Execution plans.
- Index design.
- I/O.
- Memory.
- Locking.
- CPU.
- Buffer behavior.
- pg_stat_statements.
- Data distribution.
- Partitioning.
- Application query patterns.
105. Skills Expected from a Database Reliability Engineer
Combine PostgreSQL with:
- SRE principles.
- Linux.
- Networking.
- Cloud.
- Automation.
- Monitoring.
- Incident response.
- HA.
- Disaster recovery.
- Capacity planning.
- Infrastructure as Code.
106. Practical Project 1: E-Commerce Database
Build:
- Customer.
- Product.
- Category.
- Inventory.
- Order.
- Order item.
- Payment.
- Shipment.
Implement:
- Constraints.
- Transactions.
- Indexes.
- Audit trail.
- Search.
- Pagination.
- Reporting.
- Partitioned order history.
Then generate realistic volumes and optimize actual queries.
107. Practical Project 2: Banking Transaction System
Build:
- Customer.
- Account.
- Transaction.
- Beneficiary.
Practice:
- ACID transactions.
- Row locking.
- Concurrent transfers.
- Deadlock handling.
- Auditability.
- Isolation levels.
- Retry logic.
Caution: Do not present the project as a real banking-grade implementation. Use it to learn transactional concepts safely.
108. Practical Project 3: Multi-Tenant SaaS
Build:
tenant
user
subscription
invoice
application_data
Implement:
- tenant_id strategy.
- Role security.
- Row-Level Security.
- Index strategy.
- Tenant-aware queries.
- Backup design.
Compare this with schema-per-tenant architecture.
109. Practical Project 4: Large Event Database
Generate millions of events.
Fields:
event_id
user_id
event_type
payload
created_at
Practice:
- JSONB.
- GIN indexes.
- Time partitioning.
- BRIN.
- Bulk loading.
- Data retention.
- Aggregation.
- Query tuning.
110. Practical Project 5: Production-Like PostgreSQL Environment
Create:
Application
|
Connection Pool
|
PostgreSQL Primary
|
PostgreSQL Standby
Add:
- Backups.
- Monitoring.
- Logging.
- Replication.
- Restore testing.
- Simulated failover.
This project provides more professional value than writing dozens of isolated SQL examples.
111. 16-Week PostgreSQL Learning Plan
Weeks 1-2: SQL Refresh and Advanced SQL
Cover:
- Advanced joins.
- CTE.
- Recursive SQL.
- Window functions.
- Aggregation.
- Subqueries.
- Set operations.
- Advanced DML.
Practice difficult SQL problems.
Weeks 3-4: Schema and Index Design
Learn:
- Normalization.
- Constraints.
- Data types.
- B-tree.
- GIN.
- GiST.
- BRIN.
- Partial indexes.
- Expression indexes.
- Composite indexes.
- Covering indexes.
Build an e-commerce schema.
Weeks 5-6: Query Performance
Master:
- EXPLAIN.
- EXPLAIN ANALYZE.
- BUFFERS.
- Statistics.
- Planner estimates.
- Join strategies.
- Sequential scan.
- Index scan.
- Sort/hash behavior.
Take intentionally slow queries and tune them.
Weeks 7-8: Transactions and MVCC
Study:
- Transactions.
- Isolation.
- MVCC.
- Locks.
- Deadlocks.
- VACUUM.
- Autovacuum.
- Bloat.
- Long-running transactions.
Simulate concurrency with multiple database sessions.
Weeks 9-10: Administration
Learn:
- Configuration.
- Users.
- Roles.
- Security.
- Logging.
- Monitoring.
- Database size.
- Connections.
- Routine maintenance.
Weeks 11-12: Backup, Recovery and Replication
Practice:
- pg_dump.
- pg_restore.
- Physical backup concepts.
- WAL archiving.
- PITR.
- Streaming replication.
- Replication monitoring.
Perform an actual restore in your practice environment.
Weeks 13-14: Advanced Architecture
Cover:
- Partitioning.
- JSONB.
- Full-text search.
- Materialized views.
- Extensions.
- FDW.
- Connection pooling.
- HA.
- Read scaling.
Weeks 15-16: Production and Interview Preparation
Practice:
- Performance incidents.
- Lock incidents.
- Connection incidents.
- Replica lag.
- Storage growth.
- Failed deployment.
- Schema migration.
- PostgreSQL upgrade planning.
Then prepare project explanations for interviews.
112. What to Practice Every Day
For experienced professionals, use a cycle such as:
Learn concept
↓
Build example
↓
Generate realistic data
↓
Run query
↓
Examine execution plan
↓
Create or modify index
↓
Test again
↓
Explain why performance changed
That final explanation is where experienced-level learning happens.
113. PostgreSQL Interview Preparation Areas
Prepare deeply in these areas:
SQL
- Joins.
- Window functions.
- CTE.
- Recursive queries.
- Aggregation.
- Subqueries.
Indexing
- Index types.
- Composite indexes.
- Partial indexes.
- Expression indexes.
- Index selectivity.
- Index-only scans.
Performance
- EXPLAIN ANALYZE.
- Planner.
- Statistics.
- Slow queries.
- Memory.
- I/O.
Transactions
- ACID.
- Isolation.
- MVCC.
- Locks.
- Deadlocks.
Maintenance
- VACUUM.
- Autovacuum.
- ANALYZE.
- Bloat.
Administration
- Roles.
- Security.
- Configuration.
- Monitoring.
Reliability
- Backup.
- Recovery.
- PITR.
- Replication.
- HA.
Architecture
- Partitioning.
- Scaling.
- Pooling.
- Cloud.
- Migrations.
114. How Experienced Candidates Should Answer Interview Questions
Caution: Avoid textbook-only answers.
Question:
How would you troubleshoot a slow PostgreSQL query?
Weak answer:
Note: I would create an index.
Experienced answer:
Note: I would first reproduce or identify the exact query and determine whether the problem is isolated or system-wide. I would inspect workload statistics and the execution plan, compare estimated and actual row counts, check scan and join strategies, buffer usage, sorting or temporary I/O, statistics freshness, blocking, and recent data or deployment changes. I would add or modify an index only when the query pattern and plan justify it.
The second answer shows production reasoning.
115. PostgreSQL Job Opportunities
PostgreSQL knowledge can support several career paths.
PostgreSQL Developer
Typical work:
- SQL development.
- Functions.
- Schema design.
- Query optimization.
- Application integration.
Senior PostgreSQL Developer
Typical work:
- Complex SQL.
- Data modeling.
- Performance tuning.
- Database design review.
- Production troubleshooting.
- Migration design.
PostgreSQL DBA
Typical work:
- Installation.
- Configuration.
- User administration.
- Backup.
- Recovery.
- Replication.
- Monitoring.
- Maintenance.
- Upgrades.
Database Engineer
Combines:
- Database development.
- Administration.
- Automation.
- Performance engineering.
- Cloud architecture.
Database Reliability Engineer
Focuses on:
- Availability.
- Reliability.
- Automation.
- Monitoring.
- Disaster recovery.
- Incident response.
PostgreSQL Performance Engineer
Specializes in:
- Query plans.
- Index design.
- Planner statistics.
- System tuning.
- Workload optimization.
Backend Engineer
PostgreSQL expertise is highly valuable for backend engineers working on:
- APIs.
- Microservices.
- Transactional systems.
- SaaS applications.
- Enterprise systems.
Data Engineer
PostgreSQL skills help with:
- ETL.
- ELT.
- Data transformation.
- Data ingestion.
- Analytical processing.
- Pipeline development.
Cloud Database Engineer
Typical responsibilities include:
- Managed PostgreSQL.
- High availability.
- Backup.
- Cloud networking.
- Security.
- Monitoring.
- Scaling.
Migration Engineer
Typical work:
- Oracle to PostgreSQL.
- SQL Server to PostgreSQL.
- MySQL to PostgreSQL.
- PostgreSQL major-version migration.
- On-premises to cloud migrations.
Platform Engineer / SRE
PostgreSQL knowledge is useful when maintaining:
- Application platforms.
- Kubernetes environments.
- Cloud infrastructure.
- Observability.
- Automated deployment systems.
116. Skills That Increase PostgreSQL Career Value
Combine PostgreSQL with one or more of:
- Java and Spring Boot.
- Python.
- Node.js.
- .NET.
- Linux.
- Docker.
- Kubernetes.
- AWS.
- Azure.
- Google Cloud.
- Terraform.
- Bash.
- Monitoring systems.
- CI/CD.
- Data engineering technologies.
A database professional who understands both database internals and the applications using the database can diagnose problems across system boundaries.
117. Common Mistakes Made by Experienced Developers
Mistake 1: Creating an Index for Every Column
Every index has maintenance and storage cost.
Mistake 2: Using SELECT *
Retrieve required columns when possible.
Mistake 3: Ignoring Execution Plans
SQL that returns correct results can still be operationally expensive.
Mistake 4: Keeping Transactions Open Too Long
This increases lock and MVCC-related problems.
Mistake 5: Assuming VACUUM FULL Is Routine Maintenance
It is a heavier operation and should not become a default cleanup command.
Mistake 6: Increasing max_connections Without Investigation
This can shift rather than solve resource problems.
Mistake 7: Putting Everything in JSONB
Flexible storage does not eliminate relational modeling requirements.
Mistake 8: Partitioning Small Tables
Partitioning introduces management overhead.
Mistake 9: Applying Configuration from Random Examples
Database tuning depends on workload and environment.
Mistake 10: Running Production DDL Without Checking Locks
A seemingly simple migration can cause application blocking.
Mistake 11: Ignoring Generated ORM Queries
ORM abstraction does not remove responsibility for SQL performance.
Mistake 12: Treating Backups as Successful Without Restore Tests
Recovery capability matters more than the existence of backup files.
Mistake 13: Ignoring Replication Slots
Inactive slots can contribute to retained WAL and storage growth.
Mistake 14: Using a Database Superuser from the Application
Use restricted runtime roles instead.
Mistake 15: Optimizing Before Measuring
Performance tuning should start from observable evidence.
118. PostgreSQL Working-Experience Checklist
You can consider yourself strong at experienced-level PostgreSQL when you can confidently explain and demonstrate:
- Advanced SQL.
- Window functions.
- CTEs.
- Index types.
- Composite indexes.
- Partial indexes.
- Expression indexes.
- EXPLAIN ANALYZE.
- Query planner behavior.
- Statistics.
- MVCC.
- Transaction isolation.
- Locks.
- Deadlocks.
- VACUUM.
- Autovacuum.
- Partitioning.
- JSONB.
- Materialized views.
- Functions.
- Procedures.
- Triggers.
- Roles.
- RLS.
- Backup.
- Restore.
- PITR.
- WAL.
- Replication.
- HA concepts.
- Connection pooling.
- pg_stat_statements.
- Database monitoring.
- Slow-query troubleshooting.
- Schema migrations.
- Major upgrades.
- Cloud PostgreSQL.
- Application/database performance interaction.
Frequently Asked Questions
1. Is SQL knowledge enough for an experienced PostgreSQL developer?
No. SQL is the foundation, but experienced professionals also need indexing, execution plans, transactions, MVCC, locking, maintenance, monitoring, security, and production troubleshooting.
2. What is the most important PostgreSQL skill for an experienced backend developer?
Query-plan analysis is one of the highest-value skills because it connects SQL, indexes, statistics, data distribution, and actual performance.
3. Should an experienced developer learn PostgreSQL administration?
Yes, at least enough to understand connections, configuration, VACUUM, monitoring, backup, replication, and production failure modes.
4. What should I learn first: advanced SQL or PostgreSQL internals?
Start with advanced SQL and query plans, then learn MVCC, VACUUM, WAL, storage, and planner internals.
5. What is MVCC?
Multi-Version Concurrency Control is PostgreSQL's concurrency model based on row versions and transaction visibility. It allows readers and ordinary writers to operate with limited mutual blocking.
6. Why does PostgreSQL create dead tuples?
Updates and deletes can leave row versions that are no longer visible to active transactions. VACUUM later makes associated space reusable according to PostgreSQL's MVCC rules.
7. Why is VACUUM required?
VACUUM handles maintenance associated with obsolete row versions and is also part of protecting PostgreSQL against transaction-ID-related issues. Autovacuum automates routine vacuum operations.
8. Is VACUUM FULL better than VACUUM?
Not generally. VACUUM FULL performs a table rewrite and requires heavier locking. It is used for specific situations rather than normal routine maintenance.
9. What is ANALYZE?
ANALYZE collects statistics used by PostgreSQL's query planner to estimate data distribution and select execution strategies.
10. Why is my index not being used?
The planner may estimate that another plan is cheaper. Causes can include low selectivity, a small table, stale statistics, inappropriate index design, mismatched predicates, or a query returning a substantial fraction of the table.
11. Should I force PostgreSQL to use an index?
Usually the better approach is to understand why the planner selected another plan rather than forcing a particular access method.
12. What is EXPLAIN ANALYZE?
It executes the statement and reports the actual execution behavior in addition to planner estimates.
Use caution when applying it to statements that modify data or to expensive production workloads.
13. What is the difference between estimated rows and actual rows?
Estimated rows come from planner statistics and estimation logic.
Actual rows represent what occurred during execution.
Large differences can indicate cardinality-estimation problems.
14. What is a sequential scan?
PostgreSQL reads table pages sequentially rather than using an index access path.
A sequential scan is not automatically a performance problem.
15. When is a sequential scan good?
It can be efficient when:
- The table is small.
- A large percentage of rows is required.
- Index access would result in more random work than scanning the table.
16. What is a composite index?
An index containing multiple key columns.
Example:
CREATE INDEX idx_order_customer_date
ON orders(customer_id, created_at);
Its usefulness depends strongly on query patterns and column ordering.
17. What is a partial index?
An index containing only rows matching a predicate.
It can reduce index size and maintenance for suitable workloads.
18. What is an expression index?
An index built from an expression rather than only a raw column.
Example:
CREATE INDEX idx_email_lower
ON customer(lower(email));
19. What is BRIN useful for?
BRIN can be useful for very large tables where indexed values correlate well with physical data order, such as some append-heavy time-series datasets.
20. Should every foreign key have an index?
PostgreSQL does not automatically create an index on every referencing foreign-key column. Whether one should be added depends on query patterns and modification behavior, though such indexes are frequently useful in real applications.
21. What is the default transaction isolation level?
PostgreSQL commonly operates with Read Committed as its default isolation level. Applications should still understand stronger isolation levels and their retry requirements.
22. What is a deadlock?
A deadlock occurs when transactions wait on each other in a cycle that cannot resolve naturally. PostgreSQL detects the condition and aborts a transaction to break the cycle.
23. How can deadlocks be reduced?
Use:
- Consistent lock order.
- Short transactions.
- Focused updates.
- Proper indexing.
- Suitable retry logic.
24. Why are long transactions dangerous?
They can retain locks, delay MVCC cleanup, increase dead tuples, and complicate maintenance and recovery.
25. What is WAL?
WAL stands for Write-Ahead Log.
PostgreSQL records changes in WAL before the corresponding data changes are considered safely persisted according to its durability process. WAL also underpins recovery and replication.
26. What is a checkpoint?
A checkpoint establishes a recovery point and coordinates flushing of dirty buffers as part of PostgreSQL's durability and recovery mechanisms.
27. What is streaming replication?
It is PostgreSQL's physical replication approach where WAL changes from a primary are continuously transmitted and replayed on standby systems.
28. What is replication lag?
Replication lag represents how far a replica is behind the primary according to the measurement being used.
It should be monitored because connected does not necessarily mean fully caught up.
29. What is a replication slot?
A replication slot tracks a replication consumer's progress and can retain required WAL.
Unused slots must be monitored because retained WAL can consume storage.
30. What is logical replication?
Logical replication transfers logical data changes through publication/subscription mechanisms rather than replicating the entire physical database cluster.
31. Physical or logical replication: which is better?
Neither is universally better.
Physical replication is commonly suited to full standby replicas.
Logical replication is useful when selective data replication or certain migration/integration requirements exist.
32. What is PITR?
Point-in-Time Recovery combines a base backup with archived WAL so a database can be recovered toward a chosen point in its transaction history.
33. Is pg_dump enough for enterprise backup?
It can be part of a backup strategy, but recovery requirements may also require physical backups, WAL archiving, PITR, replicas, off-site storage, and tested disaster-recovery procedures.
34. How often should backups be taken?
The answer should come from business RPO and RTO requirements rather than a universal schedule.
35. What is RPO?
Recovery Point Objective defines how much recent data loss the business can tolerate.
36. What is RTO?
Recovery Time Objective defines how long the service can remain unavailable after an incident.
37. How many PostgreSQL connections should an application use?
There is no universal number.
Pool size should reflect:
- Workload.
- Database resources.
- Number of application instances.
- Query duration.
- Concurrency requirements.
38. Why use PgBouncer?
PgBouncer can reduce the cost of maintaining large numbers of PostgreSQL server connections by providing connection pooling.
39. Should max_connections simply be increased when the application runs out of connections?
No.
First investigate:
- Leaks.
- Idle transactions.
- Pool sizing.
- Query duration.
- Application scaling.
40. Is JSONB a replacement for relational tables?
No.
JSONB is useful for semi-structured data, but relational columns, constraints, and relationships remain more appropriate for many business-critical attributes.
41. Should I use PostgreSQL instead of a document database for JSON workloads?
That depends on workload requirements.
Evaluate:
- Transaction requirements.
- Query patterns.
- Schema flexibility.
- Scale.
- Indexing.
- Operational ecosystem.
Caution: Avoid technology decisions based solely on the existence of a JSON data type.
42. What is table partitioning?
Partitioning divides one logical table into physical partitions based on a partitioning strategy such as range, list, or hash.
PostgreSQL can prune irrelevant partitions for suitable queries.
43. When should I partition a table?
When data volume, query patterns, retention, or maintenance requirements demonstrate a clear benefit.
Caution: Do not partition only because a table has reached an arbitrary row count.
44. What is a materialized view?
It stores the result of a query physically and requires refresh when source data changes.
45. What is REFRESH MATERIALIZED VIEW CONCURRENTLY?
It refreshes a materialized view while allowing concurrent reads, subject to PostgreSQL's requirements such as an appropriate UNIQUE index.
46. Should business logic be placed in PostgreSQL functions?
Some logic fits well in database functions, especially data-oriented operations.
However, placing all application behavior in stored logic can make deployment, testing, ownership, and service architecture harder.
Choose deliberately.
47. Are triggers bad?
No.
Hidden, undocumented, complex triggers are problematic.
Well-designed triggers can be useful for carefully chosen auditing, integrity, or synchronization requirements.
48. What is Row-Level Security?
RLS allows policies to control which rows a database role can access or modify.
It is particularly useful in some multi-tenant and security-sensitive architectures.
49. Should the application connect as the postgres user?
No for normal application runtime.
Create a dedicated application role with only required permissions.
50. What is pg_stat_activity?
It is a PostgreSQL system view that shows activity associated with server processes/sessions and is fundamental when investigating active queries, waits, and session states.
51. What is pg_stat_statements?
It is an extension that collects planning and execution statistics for SQL statements, making it highly useful for workload-level performance analysis.
52. How do I find slow queries?
Combine:
- pg_stat_statements.
- PostgreSQL logging.
- Application tracing.
- Execution plans.
- System monitoring.
Caution: Do not rely on one metric alone.
53. How do I troubleshoot CPU utilization at 100%?
Determine:
- Which queries consume CPU.
- Whether query volume increased.
- Whether plans changed.
- Whether scans or joins are inefficient.
- Whether parallelism contributes.
- Whether application retries are amplifying load.
54. What causes high PostgreSQL disk I/O?
Possible causes include:
- Sequential scans.
- Low cache effectiveness.
- Large sorts or hashes spilling to disk.
- Checkpoint activity.
- VACUUM.
- Backup.
- Bulk writes.
- Table/index bloat.
55. What causes PostgreSQL database bloat?
Common contributing factors include high UPDATE/DELETE activity combined with insufficient cleanup or long-running transactions that prevent obsolete versions from becoming reusable.
56. Can indexes become bloated?
Yes.
Index health can also require investigation in update-heavy workloads.
Caution: Do not rebuild indexes on a fixed schedule without evidence.
57. What is REINDEX?
REINDEX rebuilds an index.
Use it for specific maintenance scenarios rather than as a substitute for understanding underlying workload behavior.
58. What is a hot standby?
A standby server configured so read-only queries can run while WAL recovery continues.
59. Can all reads safely go to replicas?
Not automatically.
Applications must consider replication lag and consistency requirements.
60. How should PostgreSQL be scaled?
Start by determining the bottleneck.
Possible actions include:
- Query tuning.
- Index optimization.
- Application optimization.
- Connection pooling.
- Hardware scaling.
- Read replicas.
- Partitioning.
- Architectural changes.
Caution: Do not begin with sharding.
61. When is sharding required?
Usually when a workload cannot be handled adequately by a single database architecture even after reasonable optimization and scaling.
Sharding should solve a measured scalability problem.
62. Is PostgreSQL suitable for microservices?
Yes, PostgreSQL can support microservice architectures, but database ownership and service boundaries should be designed deliberately.
63. Should each microservice have a separate database?
It is one common architectural approach, but infrastructure, operational complexity, cross-service consistency, and team ownership must be considered.
64. What is the N+1 query problem?
An application first loads one collection and then executes another query for each item.
For 1,000 records this could generate roughly 1,001 database calls instead of a small number of well-designed queries.
65. How can ORM performance issues be found?
Enable suitable SQL observability and examine:
- Generated statements.
- Query count.
- Execution time.
- Execution plans.
- Loaded columns.
- Relationship fetching.
66. OFFSET or keyset pagination?
OFFSET is simple and appropriate for many small result sets.
Keyset pagination can perform better for deep pagination when a stable ordering key exists.
67. Is SELECT * bad?
Not universally, but production application queries should generally retrieve only required data when row width or network transfer matters.
68. Should SQL queries be written inside application code or stored procedures?
Both approaches have valid use cases.
Choose based on:
- Complexity.
- Deployment ownership.
- Performance.
- Testing.
- Reusability.
- Architecture.
69. How should large imports be performed?
Depending on requirements, consider:
- COPY.
- Batched inserts.
- Staging tables.
- Appropriate indexes and constraints.
- Post-load ANALYZE.
COPY is PostgreSQL's native bulk data transfer facility.
70. Should indexes be created before or after a bulk load?
The right strategy depends on workload, table state, constraints, availability requirements, and index build cost.
For very large initial loads, creating some indexes after loading can sometimes be more efficient, but production requirements must be evaluated.
71. Why should ANALYZE be considered after a large data load?
A major change in data distribution can make existing planner statistics inaccurate. Updated statistics help the planner choose better execution plans.
72. What should I monitor every day in production?
At minimum monitor:
- Availability.
- Errors.
- Connections.
- Query latency.
- Long transactions.
- Blocking.
- Disk capacity.
- WAL.
- Replication.
- Autovacuum.
- Backup status.
73. Is cloud-managed PostgreSQL maintenance-free?
No.
The provider may manage infrastructure functions, but teams still own:
- Schema design.
- SQL.
- Indexes.
- Capacity decisions.
- Application transactions.
- Security configuration.
- Query performance.
- Recovery requirements.
74. Should I learn PostgreSQL on Docker?
Yes for development and experimentation.
Also learn enough Linux and PostgreSQL administration to understand what the container is abstracting.
75. Do I need Linux for PostgreSQL jobs?
For developer roles, basic Linux may be enough.
For DBA, SRE, platform, and database-engineering roles, stronger Linux skills are highly valuable.
76. Should I learn Bash or Python?
Yes if your role involves automation.
Python and shell scripting are useful for operational tasks and database tooling.
77. Do I need Kubernetes?
Not for every PostgreSQL role.
It becomes more relevant for cloud/platform/SRE environments.
PostgreSQL fundamentals should come before Kubernetes-specific database operations.
78. Which PostgreSQL version should I learn in 2026?
Use a supported modern release and understand the version used by your employer. PostgreSQL 18 is the current major release as of August 2026, while PostgreSQL 19 remains a development release.
79. How often does PostgreSQL release major versions?
PostgreSQL uses a major-version lifecycle in which supported major versions receive fixes for five years. Professionals responsible for production systems should monitor the official version lifecycle rather than allowing databases to remain indefinitely on unsupported releases.
80. How should a major PostgreSQL upgrade be performed?
Depending on requirements, PostgreSQL supports approaches including:
- Dump/restore.
- pg_upgrade.
- Logical replication.
Production upgrades should first be rehearsed in a representative environment.
Final Experienced-Level Roadmap
Follow this learning order:
Advanced SQL
↓
Data Modeling
↓
Advanced Data Types
↓
Index Design
↓
EXPLAIN / EXPLAIN ANALYZE
↓
Query Planner and Statistics
↓
Transactions
↓
MVCC
↓
Locks and Deadlocks
↓
VACUUM and Autovacuum
↓
Functions / Procedures / Triggers
↓
JSONB / Full-Text Search
↓
Partitioning
↓
Security and Roles
↓
Connection Management
↓
PostgreSQL Configuration
↓
Monitoring
↓
pg_stat_statements
↓
Backup and Restore
↓
WAL and PITR
↓
Physical Replication
↓
Logical Replication
↓
High Availability
↓
Cloud PostgreSQL
↓
Schema Migration
↓
PostgreSQL Major Upgrades
↓
Production Troubleshooting
↓
Performance Engineering
↓
PostgreSQL Architecture
For a working experienced professional, give the highest priority to five capabilities:
- Read and explain execution plans rather than guessing about query performance.
- Understand MVCC, transactions, locking, VACUUM, and concurrency well enough to diagnose production behavior.
- Design indexes according to workload, selectivity, data distribution, and write cost.
- Operate PostgreSQL safely through monitoring, backups, recovery, replication, security, and controlled migrations.
- Connect application behavior with database behavior, because many PostgreSQL incidents originate at the boundary between SQL, connection pools, ORM behavior, transaction design, infrastructure, and production workload.
That combination moves PostgreSQL knowledge from "I have worked with PostgreSQL" to "I can design, optimize, troubleshoot, and operate PostgreSQL-backed production systems."