(This page has no text content)
PostgreSQL 16 Administration Cookbook Solve real-world Database Administration challenges with 180+ practical recipes and best practices Gianni Ciolli Boriss Mejías Jimmy Angelakos Vibhor Kumar Simon Riggs BIRMINGHAM—MUMBAI
PostgreSQL 16 Administration Cookbook Copyright © 2023 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. Senior Publishing Product Manager: Gebin George Acquisition Editor – Peer Reviews: Swaroop Singh Project Editor: Parvathy Nair Content Development Editors: Davide Oliveri, Elliot Dallow, Soham Amburle Copy Editor: Safis Editing Technical Editor: Aniket Shetty Proofreader: Safis Editing Indexer: Manju Arasan Presentation Designer: Ganesh Bhadwalkar Developer Relations Marketing Executive: Vignesh Raju First published: December 2023 Production reference: 1301123 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul’s Square Birmingham B3 1RB, UK. ISBN 978-1-83546-058-0 www.packt.com
Boriss, Gianni, Jimmy, and Vibhor are grateful to Simon Riggs, for having been the main author of all the past editions of this book. They hope that, by joining forces, they were able to continue that high standard.
Contributors About the authors Gianni Ciolli is Vice President and Field CTO at EDB; he was Global Head of Professional Services at 2ndQuadrant until it was acquired by EDB. Gianni has been a PostgreSQL consultant, trainer, and speaker at many PostgreSQL conferences in Europe and abroad for more than 10 years. He has a PhD in Mathematics from the University of Florence. He has worked with free and Open- Source software since the 1990s and is active in the community. He lives between Frankfurt and London and plays the piano in his spare time. Gianni has learned a lot from his colleagues and customers over the years and would like to thank them. Boriss Mejías is a Senior Solutions Architect at EDB, building on his experience as PostgreSQL consultant and trainer at 2ndQuadrant. He has been working with Open-Source software since the beginning of the century, contributing to several projects both with code and community work. He has a PhD in Computer Science from the Université catholique de Louvain, and an En- gineering degree from Universidad de Chile. Complementary to his role as Solutions Architect, he gives PostgreSQL training and is a regular speaker at PostgreSQL conferences. He loves spending time with his family and playing air guitar. I would like to thank my co-authors for the great collaboration in writing this book. It has been a great experience. I would also like to thank the PostgreSQL community for everything I have learned from them during all these years. Special thanks to my family for all their support, laughs, and daily fun.
Jimmy Angelakos is a Systems and Database Architect and recognized PostgreSQL expert, with a wealth of experience gained from his career in Software Architecture and his key roles at 2nd- Quadrant and EDB. He studied Computer Science at the University of Aberdeen and has worked with, and contributed to, Open Source tools for 25+ years. He is passionate about participating in the community, and is an active member of PostgreSQL Europe and an occasional contributor to the PostgreSQL project. He is a regular speaker at conferences and events focused on databases and Open Source software, sharing his insights with the community. No one is an island, and none of this would have been possible without the mentoring, knowledge sharing, and guidance that the PostgreSQL community has so generously provided to me over the years. Vibhor Kumar, Global VP at EDB, is a pioneering data tech leader. He manages a global team of engineers, optimizing clients’ Postgres databases for peak performance and scalability. He advises Fortune 500 clients, including many financial institutes, on innovating and transforming their data platforms. His past experience spans IBM, BMC Software, and CMC Ltd. He holds a BSc in Computer Science from the University of Lucknow and a Master’s from the Army Institute of Management. As a certified expert in numerous technologies, he often shares his insights on DevOps the cloud, and database optimization through blogging and speaking at events. I’m thankful to everyone who supported this project. Special thanks to my wife, Nandini Karkare, for her constant support and love. I’m also grateful to my colleagues and co-authors for their insights and contributions and to Marc Linster for his mentorship. This book is a result of our collective efforts. Thank you all for being part of this journey. Simon Riggs is a Major Developer of PostgreSQL since 2004. Formerly, Simon was Founder and CEO of 2ndQuadrant, acquired by EDB in 2020. Simon has contributed widely to PostgreSQL, initiating new projects, contributing ideas, and committing many important features, as well as working directly with database architects and users on advanced solutions.
About the reviewers Marcelo Diaz is a Software Engineer with more than 15 years of experience, with a special focus on PostgreSQL. He is passionate about Open-Source software and has promoted its application in critical and high-demand environments, working as a software developer and consultant for both private and public companies. He currently works very happily at Cybertec and as a technical reviewer for Packt Publishing. He enjoys spending his leisure time with his daughter, Malvina, his wife, Romina, and their pets. He also likes to play “fulbo”, but currently he enjoys it more watching Messi on TV. Martín Marqués began his career as a DBA and Software Developer at a local university in Argentina over 20 years ago. He dedicated 13 years to these roles, during which he provided train- ing using custom materials to various agencies. Later, he transitioned to a technical support role, specializing in remote DBA services and consulting for clients at 2ndQuadrant. In recent years, Martín shifted into a management role within technical support at EnterpriseDB. In the past year, he has taken on the position of Engineering Manager for five EnterpriseDB products. Afroditi Loukidou is a PostgreSQL and Open-Source enthusiast, currently working as a Tech- nical Lead at EnterpriseDB. She has studied Industrial Informatics and holds an MSc in Computer Networks. Her journey with PostgreSQL started at 2ndQuadrant and went on with EDB, where she has gained a wealth of experience working as a PostgreSQL engineer assisting smaller and bigger customers with PostgreSQL operational aspects, maintenance, tuning, upgrades and more. In her role as a Technical Lead, she also gets exposure to more architectural aspects and larger- scale projects of varied complexity and has always found this book to be a great resource to turn to. She lives in London and loves music, mountaineering, and generally spending time in nature.
Learn more on Discord To join the Discord community for this book – where you can share feedback, ask questions to the author, and learn about new releases – follow the QR code below: https://discord.gg/pQkghgmgdG
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
(This page has no text content)
Table of Contentsxiv Setting the configuration parameters for the database server 93 Getting ready • 93 How to do it… • 94 How it works… • 97 There’s more… • 97 Setting the configuration parameters in your programs 99 How to do it… • 100 How it works… • 101 There’s more… • 101 Finding the configuration settings for your session 102 How to do it… • 102 How it works… • 104 Finding parameters with non-default settings 104 How to do it… • 105 How it works... • 105 There’s more... • 105 Setting parameters for particular groups of users 106 How to do it… • 106 How it works… • 106 A basic server configuration checklist 107 Getting ready • 107 How to do it… • 107 There’s more… • 108 Adding an external module to PostgreSQL 109 Getting ready • 110 How to do it… • 110 Installing modules using a software installer • 110 Installing modules from PGXN • 111 Installing modules from source code • 112 How it works... • 112
(This page has no text content)
(This page has no text content)
Table of Contents xvii There’s more… • 150 Running multiple PgBouncer on the same port to leverage multiple cores 150 Getting ready • 150 How to do it… • 151 How it works… • 152 Chapter 5: Tables and Data 153 Choosing good names for database objects 154 Getting ready • 154 How to do it… • 154 There’s more… • 155 Handling objects with quoted names 156 Getting ready • 157 How to do it... • 157 How it works… • 158 There’s more… • 158 Identifying and removing duplicates 159 Getting ready • 159 How to do it… • 160 How it works… • 162 There’s more… • 163 Preventing duplicate rows 164 Getting ready • 164 How to do it… • 164 How it works… • 167 There’s more... • 167 Duplicate indexes • 167 Uniqueness without indexes • 167 A real-world example – IP address range allocation • 168 A real-world example – a range of time • 169
(This page has no text content)
(This page has no text content)
Loading comments...
Reply to Comment
Edit Comment