Architecture, Operations, and Performance Tuning for Production Systems
Introduction: Why PostgreSQL Administration Matters
Chapter 1: Understanding PostgreSQL Architecture
- The Client-Server Model and Process Architecture
- Shared Memory and Background Processes
- Multiversion Concurrency Control (MVCC) Explained
- Write-Ahead Logging and the WAL Pipeline
- Storage Layout: Tables, Indexes, and Catalogs
- Chapter 1 Summary
Chapter 2: Installation and Initial Configuration
- Choosing an Installation Method: Packages vs Source vs Containers
- Initializing the Database Cluster with initdb
- Understanding postgresql.conf and Its Include Chain
- Configuring pg_hba.conf for Access Control
- Setting Up PostgreSQL as a System Service
- Hands-on Lab: Install and Configure PostgreSQL
- Chapter 2 Summary
Chapter 3: Authentication, Security, and Role Management
- Authentication Methods: trust, peer, md5, scram-sha-256, and Certificate-Based
- Designing a Secure pg_hba.conf Strategy
- Setting Up SSL/TLS for Encrypted Connections
- Roles, Privileges, and the Principle of Least Privilege
- Row-Level Security and Data Encryption at Rest
- Hands-on Lab: Security Configuration
- Chapter 3 Summary
Chapter 4: Configuration Deep Dive: Memory, WAL, and Performance Parameters
- Memory Configuration: shared_buffers, work_mem, and effective_cache_size
- WAL and Checkpoint Tuning for Write Workloads
- Connection Management and max_connections
- Autovacuum Parameters and When to Override Defaults
- Query Planner Settings and Cost Parameters
- Hands-on Lab: Configuration Tuning
- Chapter 4 Summary
Chapter 5: Backup Strategies and Point-in-Time Recovery
- Backup Strategy Fundamentals: RPO, RTO, and Method Selection
- Logical Backups with pg_dump and pg_restore
- Physical Backups with pg_basebackup
- Continuous Archiving and Point-in-Time Recovery (PITR)
- Testing Restores: The Backup That Isn’t Tested Is Not a Backup
- Hands-on Lab: Backup and Restore
- Chapter 5 Summary
Chapter 6: Replication and Data Distribution
- Streaming Replication: Architecture and Configuration
- Replication Slots and WAL Retention
- Synchronous Replication: Commit Modes and Trade-offs
- Logical Replication for Selective Data Distribution
- Monitoring Replication Lag and Failover Readiness
- Hands-on Lab: Set Up Streaming Replication
- Chapter 6 Summary
Chapter 7: High Availability and Failover
- The High Availability Problem in PostgreSQL
- Automated Failover with Patroni and Distributed Stores
- Connection Pooling with PgBouncer
- Load Balancing and Virtual IPs with HAProxy and Keepalived
- Testing Failover: Chaos Engineering for PostgreSQL
- Hands-on Lab: Set Up Patroni HA Cluster
- Chapter 7 Summary
Chapter 8: Indexing Strategies and Query Optimization
- Understanding Query Plans with EXPLAIN and EXPLAIN ANALYZE
- B-Tree Indexes: The Workhorse of PostgreSQL
- Specialized Index Types: Hash, GiST, GIN, and BRIN
- Partial, Unique, and Covering Index Strategies
- Common Query Anti-Patterns and How to Fix Them
- Hands-on Lab: Query Optimization with EXPLAIN
- Chapter 8 Summary
Chapter 9: Performance Tuning in Production
- Characterizing Your Workload: Read-Heavy vs Write-Heavy
- Hardware Considerations: CPU, RAM, Storage, and Network
- Monitoring with pg_stat_activity, pg_stat_statements, and pg_stat_progress
- Connection Pooling for High-Concurrency Applications
- I/O Optimization and Asynchronous I/O (PostgreSQL 18+)
- Hands-on Lab: Performance Monitoring
- Chapter 9 Summary
Chapter 10: Maintenance, Vacuuming, and Table Health
- The Autovacuum Daemon: Mechanics and Tuning
- Transaction ID and Multixact Wraparound Prevention
- Detecting and Managing Table and Index Bloat
- Statistics Collection: ANALYZE and Beyond
- Routine Maintenance Tasks and Scheduling
- Hands-on Lab: Maintenance and Vacuum Tuning
- Chapter 10 Summary
Chapter 11: Partitioning, Extensions, and Advanced Features
- Declarative Partitioning: Range, List, and Hash Strategies
- Partition Maintenance: ATTACH, DETACH, and Automated Management
- Essential Built-in Extensions: pg_stat_statements, pg_cron, pg_trgm
- Specialized Extensions: pgvector, TimescaleDB, PostGIS, Citus
- New Features in PostgreSQL 18: uuidv7(), Virtual Generated Columns, and More
- Hands-on Lab: Partitioning and Extensions
- Chapter 11 Summary
Chapter 12: Automation, Cloud Deployments, and Upgrades
- Automating PostgreSQL Administration with Ansible and Terraform
- Managed PostgreSQL: AWS RDS, Azure Database for PostgreSQL, GCP Cloud SQL
- Minor Version Upgrades: The Simple Path
- Major Version Upgrades: pg_upgrade and Logical Replication Migration
- Troubleshooting Common Production Issues
- Hands-on Lab: Cloud Deployment and Upgrade
- Chapter 12 Summary
