
Discover PostgreSQL, an advanced open source RDBMS known for reliability, scalability, and a rich SQL feature set including MVCC, replication, security, and user defined functions.
Learn to create and manage multiple PostgreSQL database clusters on a single server by initializing new data directories, changing ports, and connecting with psql to verify databases.
Install PostgreSQL by downloading from the official site for Windows, macOS, or Linux, run the installer, set the Postgres superuser password, and note the default port 5432.
Set PostgreSQL environment variables by adding the bin directory to the system PATH and creating Pgx data for the data directory, enabling access to utilities and cluster control.
Learn to execute an sql script from a file using psql, and redirect output to a log or csv file, demonstrated with a vehicle table and seven inserts.
Identify why the fatal role postgres does not exist error occurs when initializing a PostgreSQL cluster, and resolve it by supplying a username with initdb and using a separate port.
Learn how to check a PostgreSQL table size using pg_relation_size and pg_size_pretty, converting bytes to readable units.
Learn pg_dump, PostgreSQL's logical backup tool, to back up a single database by default and customize dumps with -f, -A, -C, -s, -t, and --inserts.
Learn to back up all databases in PostgreSQL with pg_dumpall, including schema-only or data-only dumps, using clean drop and create database commands.
Learn how pg_restore restores dot dump files produced by pg_dump, including handling custom formats and selective table restoration via -t, with a lab walkthrough.
Master file system (physical) backups of PostgreSQL by stopping the cluster and using tar to compress the data directory on Windows. Learn tar cvzf usage, backup location, and space savings.
Use the pg_basebackup utility to perform a base backup of a running Postgres cluster, copying the data directory, wal files, and configuration in tar format for point-in-time recovery and replication.
Master PostgreSQL point-in-time recovery by enabling archive mode, taking a base backup with pg_basebackup, and applying wal files to recover to a specified time.
Describe how the wal sender on the primary streams wal files to the wal receiver on the standby in streaming replication. Note wal level, max wal sender, replication slots.
Configure the master for streaming replication by setting listen addresses and hot standby, and select a wal level (minimal, replica, logical). Restart is required and monitoring replication status follows.
Demonstrates a lab setup of streaming replication between a master and standby in PostgreSQL, configuring wal_level replica, listen_addresses, and hot_standby, and using pg_basebackup to clone the standby.
Discover how vacuum in Postgres reclaims space after updates and deletes by marking row versions as dead and reusing space via the free-space map without shrinking table size.
Auto vacuum runs vacuum and analyze in the background to reclaim space and update statistics, keeping tables and indexes optimized. It prevents transaction ID wraparound and boosts query planning reliability.
Learn how autovacuum runs in PostgreSQL, tune its global settings via postgresql.conf, and adjust parameters such as nap time, analyze thresholds, cost limit, and freeze max age to optimize maintenance.
In this series we will be talking about PostgreSQL fundamentals, basics and all topics which are required for you to learn the technology and understand the concepts of PostgreSQL.
What You'll Learn:
1. PostgreSQL Fundamentals
Introduction to PostgreSQL: Understand the foundational concepts and architecture of PostgreSQL.
Postmaster Process: Learn about the crucial postmaster process and its role in database management.
Types of Shutdown: Explore different PostgreSQL shutdown modes and their appropriate use cases.
Database Cluster: Gain insights into database cluster configuration and management.
2. Installing and Setting Up PostgreSQL
Download and Installation: A step-by-step guide to downloading and installing PostgreSQL.
Environment Variables: Configure environment variables for seamless PostgreSQL operations.
3. Database and User Management
Create/Drop Database: Learn how to efficiently create and drop databases.
Create/Drop User: Master user management, including creating and removing users.
Error Handling: Resolve the common "Role 'postgres' does not exist" error.
4. PostgreSQL Tools and Commands
psql Shortcuts: Increase your productivity with essential psql command-line shortcuts.
Postmaster Process ID Check: Verify and troubleshoot the postmaster process with confidence.
Tablespaces: Manage and utilize tablespaces for optimal storage organization.
5. Backup and Restore Essentials
Introduction to Backup and Restore: Understand the importance of PostgreSQL backups.
pg_dump Utility: Learn to use pg_dump for taking backups of individual databases.
Taking Dumps: A hands-on approach to performing reliable backups.
pg_dumpall: Backup all databases in your PostgreSQL instance.
Restoration Techniques: Use psql and pg_restore utilities to recover databases.
Offline Backups: Learn how to perform offline backups for critical scenarios.
Continuous Archiving: Configure continuous archiving for real-time recovery.
File System Backup: Implement physical backups for your PostgreSQL database.
pg_basebackup Utility: Use this utility for efficient physical backups.
Point-in-Time Recovery (PITR): Recover databases to a specific point using recovery parameters.
6. Replication and High Availability
Replication Overview: Learn the significance and types of replications in PostgreSQL.
Replication Modes: Explore synchronous and asynchronous replication modes.
File-Based Replication: Understand the basics of file-based replication.
Promoting Standby: Promote a standby server to master in disaster recovery scenarios.
Streaming Replication: Set up streaming replication for real-time data consistency.
WAL Sender and Receiver Processes: Understand these critical components of streaming replication.
Replication Configuration Parameters: Configure both primary and standby servers for replication.
Replication Setup (Lab): A hands-on lab to set up streaming replication.
Monitoring Replication (Lab): Learn techniques to monitor and troubleshoot replication.
7. Database Optimization
Vacuum and AutoVacuum: Understand the importance of VACUUM operations for performance.
Full Vacuum: Learn when and how to use FULL VACUUM to reclaim space.
pg_repack Utility: Optimize tables and reclaim storage without downtime using pg_repack