Category: Performance
Huge Pages and PostgreSQL
When talking to customers, sometimes I get the question: How should PostgreSQL installations deal with huge pages and large memory allocations? In particular, experienced Oracle DBA’s are interested in the details behind PostgreSQL and Huge Pages on Linux, so I’ll try to explain it in a bit more detail in the following blog post. What […]
Forcing a join order in PostgreSQL
© Laurenz Albe 2023 Different from many other database systems, PostgreSQL does not support query hints. That makes it difficult to force the hand of the query planner when it comes to a certain join order that you know to be good. This article explains how you can influence execution plans in PostgreSQL. Why no […]
EXPLAIN (GENERIC_PLAN): New in PostgreSQL 16
© Laurenz Albe 2023 A while ago, I wrote about how difficult it is to get an execution plan for a parameterized query. The method suggested in that article works, but is still somewhat complicated. So I wrote a patch to support an EXPLAIN option GENERIC_PLAN, which provides native support for that. My patch got […]
Parallel aggregate – PostgreSQL 16 – better performance
What is a parallel aggregate? In PostgreSQL, a parallel aggregate refers to a way of processing aggregate functions (such as SUM, AVG, MAX, MIN, etc.) on large amounts of data in a parallel and distributed manner, thereby making the query execution faster. When executing an aggregate query, the database system automatically breaks up the result […]
Row locks in PostgreSQL
© Laurenz Albe 2023 The PostgreSQL documentation has some information about row locks. But typically, you cannot see them in pg_locks, and not everybody knows how they work and how to track and debug row locks. This article intends to give some insight into how PostgreSQL row locks work “under the hood”. Why are there […]
PostgreSQL: DELETE vs. TRUNCATE
Data isn’t only about storage and accumulation – sometimes it’s also about deletion, cleanup and archiving. In SQL there’s more than one way to empty a table. Two essential methods are available: DELETE TRUNCATE DELETE vs. TRUNCATE Both commands serve totally different purposes, which are sometimes not fully understood. The key difference is that DELETE […]
Pagination and the problem of the total result count
© Laurenz Albe 2022 When processing a big result set in an interactive application, you want to paginate the result set, that is, show it page by page. Everybody is familiar with that from the first web search on. You also get a button to scroll to the next page, and you get a total […]
Improving GROUP BY with CREATE STATISTICS
Analyzing time series often comes with challenges. This is especially true if you want to do a bit more than just run simple counts on values in a column. More often than not you’ll want to create a month’s report, a weekly overview and so on. This requires you to group on expressions rather than […]
JSON logs in PostgreSQL 15
As of version 15, PostgreSQL offers you the ability to write the server log in JSON format. This feature has been desired for a long time and has finally made it to PostgreSQL core. In this post we will discuss how JSON logs can be configured and what this brand new feature does for users. […]
btree vs. BRIN: 2 options for indexing in PostgreSQL data warehouses
Indexing is the key to good performance. However, people often ask: Is there an alternative to btree indexing? Can we make indexes in PostgreSQL smaller? Can we create indexes in PostgreSQL faster? And how can we index in a data warehouse? This blog will answer all those questions and show which options you have to […]
Pipeline mode for better PostgreSQL performance on slow networks
© Laurenz Albe 2022 It is known that high network latency is bad for database performance. PostgreSQL v14 has introduced “pipeline mode” for the libpq C API, which is particularly useful to get decent performance over high-latency network connections. If you are using a hosted database in “the cloud”, then this article might be interesting […]
Tuning PostgreSQL autovacuum
© Laurenz Albe 2020 In many PostgreSQL databases, you never have to think or worry about tuning autovacuum. It runs automatically in the background and cleans up without getting in your way. But sometimes the default configuration is not good enough, and you have to tune autovacuum to make it work properly. This article presents […]