Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorGianni Ciolli, Boriss Mejías, Jimmy Angelakos, Vibhor Kumar, Simon Riggs

Written by a team of well-known PostgreSQL experts, this new edition will cover all the latest updates of PostgreSQL 16 including 12+ new and improved recipes on logging, monitoring, security and high-performance Key Features • Skill-up as a database administrator by achieving improved query performance, backup, and recovery management, setting up replication and so on • Get to grips with the essentials of database management with a recipe-based approach using the latest features of PostgreSQL 16 • New and updated recipes on crucial PostgreSQL topics like Monitoring, Logging, Scalability and so on Book Description PostgreSQL has seen a huge increase in its customer base in the past few years and is becoming one of the go-to solutions for anyone who has a database-specific challenge. This PostgreSQL book touches on all the fundamentals of Database Administration in a problem-solution format. It is intended to be the perfect desk reference guide. This new edition focuses on recipes based on the new PostgreSQL 16 release. The additions include handling complex batch loading scenarios with the SQL MERGE statement, security improvements, running Postgres on Kubernetes or with TPA and Ansible, and more. This edition also focuses on certain performance gains, such as query optimization, and the acceleration of specific operations, such as sort. It will help you understand roles, ensuring high availability, concurrency, and replication. It also draws your attention to aspects like validating backups, recovery, monitoring, and scaling aspects. This book will act as a one-stop solution to all your real-world database administration challenges. By the end of this book, you will be able to manage, monitor, and replicate your PostgreSQL 16 database for efficient administration and maintenance with the best practices from experts.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# PostgreSQL 16 Administration Cookbook ## 【One-Line Pitch】 A practical, recipe-driven desk reference for PostgreSQL database administrators covering everything from first steps and configuration to security, performance tuning, replication, and high availability—with 180+ solutions updated for PostgreSQL 16. Ideal for DBAs who want concrete answers to real-world problems without wading through theory. ## 【Book Arc】 - **Opening (~0%–9%)**: Introduces the book's structure and the recipe format (Getting ready, How to do it, How it works, There's more), then covers PostgreSQL fundamentals—installation, first connection, and essential tools like psql and pgAdmin 4. - **Early (~9%–25%)**: Moves into day-to-day administration basics: secure password management with SCRAM-SHA-256, connecting to cloud/DBaaS offerings like EDB BigAnimal, and exploring the database server environment—versions, uptime, file locations, and system identifiers. - **Early (~25%–34%)**: Dives into database inspection and diagnostics: locating and interpreting server logs, measuring memory usage with shared buffers and pg_buffercache, tracking disk space, and working with extensions. - **Middle (~34%–47%)**: Covers server configuration and control—understanding pg_settings to find non-default parameters, managing extension dependencies with CASCADE, emergency server stops, multitenancy design decisions (databases vs. schemas), and setting up PgBouncer connection pooling across multiple servers. - **Middle (~47%–end of excerpts)**: Addresses data quality and performance: identifying and removing duplicate rows, simplifying complex queries, speeding up queries without rewriting them (work_mem, indexes, fillfactor), forcing index usage, parallel query, and JIT compilation. ## 【Key Takeaways】 - **Recipe format is the core structure** (Early): Every solution follows a consistent pattern—Getting ready, How to do it, How it works, There's more—making it easy to scan for answers and understand both the steps and the underlying mechanics. - **Security starts with password encryption** (Early): Use SCRAM-SHA-256 instead of the older, compromised MD5; the \password command in psql sends an already-encrypted string to the server, so plaintext never crosses the wire. - **Logs are your first diagnostic tool** (Early): The server log records messages with severity levels (LOG, FATAL, PANIC); you can control verbosity via log_min_messages, log_error_verbosity, log_line_prefix, and log_destination (stderr, csvlog, syslog, eventlog). - **pg_settings reveals your actual configuration** (Middle): Query pg_settings filtering for non-default values to see what's really been changed and where (sourcefile, sourceline); SHOW alone doesn't tell you whether a parameter differs from its default. - **Extensions have dependencies** (Middle): Use CREATE EXTENSION ... CASCADE to install required dependencies automatically; DROP EXTENSION will fail with a clear error if other objects depend on it, and CASCADE handles cleanup. - **Multitenancy requires deliberate design** (Middle): Choose between separate databases, schemas, or other isolation strategies based on security needs and future cross-analytics; note that separating tables into different databases prevents joins across them. - **PgBouncer enables connection reuse and multi-server access** (Middle): One PgBouncer instance can connect to databases on different hosts and even different PostgreSQL major versions—just configure connection strings in pgbouncer.ini. - **Performance tuning is often about targeted adjustments** (Middle): Speeding up queries without rewriting them involves increasing work_mem, setting recursive_worktable_factor, using indexes wisely, setting fillfactor for frequently-updated tables, and leveraging parallel query and JIT compilation. ## 【Reading Tips】 - **Skim the "How it works" sections first** if you're short on time—they explain the underlying mechanics and help you generalize the recipe to your own situation. - **Deep-read the security and multitenancy chapters** (around 6%–9% and 44%–47%): these involve design decisions with long-term consequences, not just quick fixes. - **Use the "There's more" sections as a springboard** for exploration—they often point to related recipes and advanced variations worth knowing. - **Pay attention to the psql meta-commands** (\d, \x, \timing, \copy, \if, etc.)—they're scattered throughout and form a powerful toolkit for daily work. - **The excerpts don't cover later chapters** on replication, upgrades, monitoring, or Kubernetes/Ansible deployment—consult the full book for those topics. ## 【Coverage Limits】 This guide is based on excerpts covering roughly the first half of the book (through ~47%). Later chapters on replication, high availability, monitoring, logging, and running PostgreSQL on Kubernetes or with TPA/Ansible are mentioned in the book description but not covered in the available material. ##
Excerpt 1
o all your real-world database administration challenges. By the end of this book, you will be able to manage, monitor, and replicate your PostgreSQL 16 data...
View in text
Excerpt 2
f, \elif, \else, and \endif Changing your password securely If you are using password authentication, then you may wish to change your password from time to...
View in text
Excerpt 3
ed by a control file, <extension name>.control, located in the SHAREDIR/extension directory, plus one or more files containing the actual extension objects....
View in text
Excerpt 4
how file sockets. SHOW VERSION Shows the pgBouncer version. Table 4.1: PgBouncer SHOW commands Accessing multiple servers using the same host and port We wil...
View in text
Excerpt 5
to do this because it makes large tables easier to manage, but also for performance reasons. Postgres has had partitioning since version 8.1, and that was kn...
View in text
Excerpt 6
oving objects between schemas • Adding/removing tablespaces • Moving objects between tablespaces • Accessing objects in other PostgreSQL databases • Accessin...
View in text
Excerpt 7
i.relname NOT LIKE''pg_toast'' AND i.reltablespace != t.reltablespace ; Chapter 7 321 CREATE VIEW potential_spammers AS SELECT customerid, spam_score(firstna...
View in text
Excerpt 8
t FROM pg_statio_user_tables, b WHERE relname=<table name>; The output will be similar to this sample: postgres=# WITH b AS (SELECT current_setting('block_si...
View in text
Tags
AI categories
DatabaseBackendTechnology
Publisher: Packt Publishing
Publish Year: 2021
Language: English
Pages: 637
File Format: PDF
File Size: 10.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…