Book description
A practical guide to administer, monitor and replicate your PostgreSQL 10 database
About This Book- Get to grips with the capabilities of PostgreSQL 10 to administer your database more efficiently
- Monitor, tune, secure and protect your database for optimal performance
- A step-by-step, recipe-based guide to help you tackle any problem in PostgreSQL 10 administration with ease
This book is for database administrators, data architects, developers, or anyone with an interest in planning for, or running, live production databases using PostgreSQL. It is most suited to those looking for hands-on solutions to any problem associated with PostgreSQL administration.
What You Will Learn- Get to grips with the newly released PostgreSQL 10 features to improve database performance and reliability
- Manage open source PostgreSQL versions 10 on various platforms.
- Explore best practices for planning and designing live databases
- Select and implement robust backup and recovery techniques in PostgreSQL 10
- Explore concise and clear guidance on replication and high availability
- Discover advanced technical tips for experienced users
PostgreSQL is a powerful, open source database management system with an enviable reputation for high performance and stability. With many new features in its arsenal, PostgreSQL 10 allows users to scale up their PostgreSQL infrastructure. This book takes a step-by-step, recipe-based approach to effective PostgreSQL administration.
Throughout this book, you will be introduced to these new features such as logical replication, native table partitioning, additional query parallelism, and much more. You will learn how to tackle a variety of problems that are basically the pain points for any database administrator - from creating tables to managing views, from improving performance to securing your database. More importantly, the book pays special attention to topics such as monitoring roles, backup, and recovery of your PostgreSQL 10 database, ensuring high availability, concurrency, and replication.
By the end of this book, you will know everything you need to know to be the go-to PostgreSQL expert in your organization.
Style and approachThe book is a step by step guide with example-driven recipes, focused on the new features of the latest PostgreSQL version10. This book will serve as a specific guide to understand and leverage useful PostgreSQL functionalities to create better and more efficient databases.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
-
1. First Steps
- Introduction
- Getting PostgreSQL
- Connecting to the PostgreSQL server
- Enabling access for network/remote users
- Using graphical administration tools
- OmniDB
- Using the psql query and scripting tool
- Changing your password securely
- Avoiding hardcoding your password
- Using a connection service file
- Troubleshooting a failed connection
-
2. Exploring the Database
- Introduction
- What version is the server?
- What is the server uptime?
- Locating the database server files
- Locating the database server's message log
- Locating the database's system identifier
- Listing databases on this database server
- How many tables are there in a database?
- How much disk space does a database use?
- How much disk space does a table use?
- Which are my biggest tables?
- How many rows are there in a table?
- Quickly estimating the number of rows in a table
- Listing extensions in this database
- Understanding object dependencies
-
3. Configuration
- Introduction
- Reading the fine manual
- Planning a new database
- Changing parameters in your programs
- Finding the current configuration settings
- Which parameters are at non-default settings?
- Updating the parameter file
- Setting parameters for particular groups of users
- The basic server configuration checklist
- Adding an external module to PostgreSQL
- Using an installed module
- Managing installed extensions
-
4. Server Control
- Introduction
- Starting the database server manually
- Stopping the server safely and quickly
- Stopping the server in an emergency
- Reloading the server configuration files
- Restarting the server quickly
- Preventing new connections
- Restricting users to only one session each
- Pushing users off the system
- Deciding on a design for multitenancy
- Using multiple schemas
- Giving users their own private database
- Running multiple servers on one system
- Setting up a connection pool
- Accessing multiple servers using the same host and port
-
5. Tables and Data
- Choosing good names for database objects
- Handling objects with quoted names
- Enforcing the same name and definition for columns
- Identifying and removing duplicates
- Preventing duplicate rows
- Finding a unique key for a set of data
- Generating test data
- Randomly sampling data
- Loading data from a spreadsheet
- Loading data from flat files
-
6. Security
- Introduction
- The PostgreSQL superuser
- Revoking user access to a table
- Granting user access to a table
- Granting user access to specific columns
- Granting user access to specific rows
- Creating a new user
- Temporarily preventing a user from connecting
- Removing a user without dropping their data
- Checking whether all users have a secure password
- Giving limited superuser powers to specific users
- Auditing database access
- Always knowing which user is logged in
- Integrating with LDAP
- Connecting using SSL
- Using SSL certificates to authenticate
- Mapping external usernames to database roles
- Encrypting sensitive data
-
7. Database Administration
- Introduction
- Writing a script that either succeeds entirely or fails entirely
- Writing a psql script that exits on the first error
- Using psql variables
- Placing query output into psql variables
- Writing a conditional psql script
- Investigating a psql error
- Performing actions on many tables
- Adding/removing columns on a table
- Changing the data type of a column
- Changing the definition of a data type
- Adding/removing schemas
- Moving objects between schemas
- Adding/removing tablespaces
- Moving objects between tablespaces
- Accessing objects in other PostgreSQL databases
- Accessing objects in other foreign databases
- Updatable views
- Using materialized views
-
8. Monitoring and Diagnosis
- Providing PostgreSQL information to monitoring tools
- Real-time viewing using pgAdmin or OmniDB
- Checking whether a user is connected
- Checking whether a computer is connected
- Repeatedly executing a query in psql
- Checking which queries are running
- Checking which queries are active or blocked
- Knowing who is blocking a query
- Killing a specific session
- Detecting an in-doubt prepared transaction
- Knowing whether anybody is using a specific table
- Knowing when a table was last used
- Usage of disk space by temporary data
- Understanding why queries slow down
- Investigating and reporting a bug
- Producing a daily summary of log file errors
- Analyzing the real-time performance of your queries
-
9. Regular Maintenance
- Controlling automatic database maintenance
- Avoiding auto-freezing and page corruptions
- Removing issues that cause bloat
- Removing old prepared transactions
- Actions for heavy users of temporary tables
- Identifying and fixing bloated tables and indexes
- Monitoring and tuning vacuum
- Maintaining indexes
- Adding a constraint without checking existing rows
- Finding unused indexes
- Carefully removing unwanted indexes
- Planning maintenance
-
10. Performance and Concurrency
- Introduction
- Finding slow SQL statements
- Collect regular statistics from pg_stat* views
- Finding out what makes SQL slow
- Reducing the number of rows returned
- Simplifying complex SQL queries
- Speeding up queries without rewriting them
- Discovering why a query is not using an index
- Forcing a query to use an index
- Using parallel query
- Using optimistic locking
- Reporting performance problems
-
11. Backup and Recovery
- Introduction
- Understanding and controlling crash recovery
- Planning backups
- Hot logical backups of one database
- Hot logical backups of all databases
- Backups of database object definitions
- Standalone hot physical database backup
- Hot physical backup and continuous archiving
- Recovery of all databases
- Recovery to a point in time
- Recovery of a dropped/damaged table
- Recovery of a dropped/damaged database
- Improving performance of backup/recovery
- Incremental/differential backup and restore
- Hot physical backups with Barman
- Recovery with Barman
-
12. Replication and Upgrades
- Replication concepts
- Replication best practices
- Setting up file-based replication – deprecated
- Setting up streaming replication
- Setting up streaming replication security
- Hot Standby and read scalability
- Managing streaming replication
- Using repmgr
- Using replication slots
- Monitoring replication
- Performance and synchronous replication
- Delaying, pausing, and synchronizing replication
- Logical replication
- Bi-directional replication
- Archiving transaction log data
- Upgrading minor releases
- Major upgrades in-place
- Major upgrades online
- Other Books You May Enjoy
Product information
- Title: PostgreSQL 10 Administration Cookbook
- Author(s):
- Release date: May 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788474924
You might also like
book
PostgreSQL 9 Administration Cookbook - Second Edition
Over 150 recipes to help you run an efficient PostgreSQL database in the cloud In Detail …
book
PostgreSQL Administration Cookbook, 9.5/9.6 Edition
Over 150 recipes to help you administer your PostgreSQL database more efficiently About This Book Get …
book
Mastering PostgreSQL 10
Master the capabilities of PostgreSQL 10 to efficiently manage and maintain your database About This Book …
book
PostgreSQL 13 Cookbook
Get to grips with building reliable, scalable, and maintainable database solutions for enterprises and production databases …