Write optimized queries. This book helps you write queries that perform fast and deliver results on time. You will see that query optimization is not a magic art available only to a limited circle of wizards. Any motivated professional can learn to write efficient queries and become competent in optimizing them. You will learn to look at the process of writing a query from the database engine's point of view, and how to "think" like a database optimizer.
The book starts with a discussion of what is a performant system and progresses to measuring performance and setting performance goals. You will be introduced to different classes of queries and to suitable optimization techniques such as the use of indexes and specific join algorithms. You will learn to read and understand query execution plans along with techniques for influencing those plans for better performance. The book covers the use of object-relational mapper systems by explaining their pitfalls and showing you how to avoid those pitfalls. The book also covers advanced topics such as the use of functions and procedures, dynamic SQL, and generated queries.
What You Will Learn
- Identify optimization goals in OLTP and OLAP systems
- Read and understand PostgreSQL execution plans
- Identify indexes that will improve query performance
- Optimize full table scans
- Distinguish between long queries and short queries
- Choose the right optimization technique for each query type
- Avoid the pitfalls of object-relational mapping systems
Who This Book Is For
IT professionals working in PostgreSQL who want to develop performant and scalable applications, anyone whose job title contains the words "database developer" or "database administrator" or who is a backend developer charged with programming database calls, and system architects involved in the overall design of application systems running against a PostgreSQL database
Henrietta Dombrovskaya is a database researcher and developer with over 35 years of academic and industrial experience. She holds a PhD in computer science from the University of Saint Petersburg, Russia. At present, she is Associate Director of Databases at Braviant Holdings, Chicago, Illinois. She is an active member of the PostgreSQL community, a frequent speaker at the PostgreSQL conference, and a local organizer of the Chicago PostgreSQL User Group. Her research interests are tightly coupled with practice and are focused on developing efficient interactions between applications and databases. She is a winner of the "Technologist of the Year" 2019 award of the Illinois Technology Association.
Boris Novikov is currently a professor in the Department of Informatics at National Research University Higher School of Economics in Saint Petersburg, Russia. He graduated from Leningrad University's School of Mathematics and Mechanics. He has worked for Saint Petersburg University for a number of years and moved to his current position in January, 2019. His research interests are in a broad area of information management and include several aspects of design, development, and tuning of databases, applications, and database management systems. He also has interests in distributed scalable systems for stream processing and analytics.
Anna Bailliekova is Senior Analyst, Data Modeling and Transformation at Zendesk. Previously, she built ETL pipelines, data warehouse resources, and reporting tools as a team lead on the Division Operations team at Epic. She has also held analyst roles on a variety of political campaigns and at Greenberg Quinlan Rosner Research. She received her undergraduate degree cum laude with College Honors in political science and computer science from Knox College in Galesburg, Illinois.
1. Why Optimize?2. Theory - Yes, We Need It!3. Join Algorithms4. Short Queries and Indexes 5. Multiple Ways to Use Indexes6. Long Queries and Full Scans7. Views and Other Database Objects8. Database Design and Performance9. The Pitfalls of ORM10. Functions11. Stored Procedures12. Dynamic SQL13. Avoiding the Pitfalls of Object-Relational Mapping14. An Ultimate Optimization Algorithm