SE Radio 583: Lukas Fittl on Postgres Performance

Topics covered
Popular Clips
Episode Highlights
Index Types
explains the various index types available in Postgres, emphasizing the default use of B-tree indexes. He notes that while B-tree is optimal for most cases, other types like GIN and GiST are better suited for specific data types and operations, such as JSONB and geospatial data 1. Choosing the right index is crucial for performance, and Fittl stresses that this responsibility lies with application developers rather than DBAs or DevOps teams 2.
A B-tree index is essentially a cached data structure that optimizes that lookup so that you don't have to manually go through each row.
---
Understanding the specific queries and their operators is key to selecting the appropriate index type.
Index Selection
Fittl discusses the complexities of index selection, highlighting the lack of built-in recommendations in Postgres compared to SQL Server. He introduces the HypoPG extension, which helps simulate the impact of hypothetical indexes on query costs 3. Additionally, he addresses common query performance issues, such as inefficient pagination using limit and offset, suggesting keyset-based pagination as a more efficient alternative 4.
Sometimes it actually makes sense to rewrite the query so that you are matching your existing indexes.
---
These insights underscore the importance of aligning query structures with existing indexes for optimal performance.
Expression Indexes
Expression indexes in Postgres allow developers to index specific query expressions, such as functions applied to columns, which can significantly enhance query performance 5. Fittl shares an example where proper indexing led to a 414x performance improvement, transforming a sluggish query into an interactive experience 6.
The database will not look at these where clauses and say, oh, they're always querying for this set of where clauses. I'll create index.
---
This highlights the critical role of developers in understanding and implementing effective indexing strategies to ensure efficient database operations.
Related Episodes


Episode 454: Thomas Richter Postgres as an OLAP database
Answers 383 questions

SE-Radio Episode 362: Simon Riggs on Advanced Features of PostgreSQL
Answers 383 questions

SE-Radio Episode 328: Bruce Momjian on the Postgres Query Planner
Answers 383 questions

SE Radio 623: Mike Freedman on TimescaleDB
Answers 383 questions

Episode 511: Ant Wilson on Supabase (Postgres as a Service)
Answers 383 questions

SE Radio 649: Lukas Gentele on Kubernetes vClusters
Answers 383 questions
SE Radio 560: Sugu Sougoumarane on Distributed SQL Databases
Answers 383 questions

SE-Radio Episode 243: RethinkDB with Slava Akhmechet
Answers 383 questions

SE Radio 605: Yingjun Wu on Streaming Databases
Answers 383 questions

SE-Radio Episode 310: Kirk Pepperdine on Performance Optimization
Answers 383 questions

SE-Radio-Show-246:-John-Wilkes-on-Borg-and-Kubernetes
Answers 383 questions

SE Radio 591: Yechezkel Rabinovich on Kubernetes Observability
Answers 383 questions

Episode 129: F# with Luke Hoban
Answers 383 questions

SE-Radio Episode 295: Michael Feathers on Legacy Code
Answers 383 questions













