Appendix A. Five optimization tips
I wrote this book to walk you through the breadth and depth of Postgres capabilities. Each chapter was designed as a hands-on technical guide that lets you open it up, spin up a Postgres container, load a sample dataset, and experience another Postgres capability in action. My goal was for you to finish each chapter thinking, “Postgres can really do that too!”
To support this kind of learning, I intentionally avoided overloading you with too many details, best practices, or pitfalls. First, because too much too soon might discourage you from using any technology in the first place. And second, because your journey with Postgres shouldn’t end with this book. Once you're done here, keep building real-world apps with Postgres and pick up more tips, tricks, and gotchas from other resources—and more importantly, from your own experience.
That said, I still couldn’t resist sharing my top five query optimization tips. These should help you write more efficient code and design better solutions with Postgres. Let’s run through them briefly.
A.1 Master using EXPLAIN
Throughout the book, we used the EXPLAIN command to analyze and compare execution plans generated by Postgres. Most of the time, a statement with EXPLAIN looked as follows:
EXPLAIN (analyze, costs off) SELECT…