Month: February 2021
Estimating connection pool size with PostgreSQL database statistics
© Laurenz Albe 2021 PostgreSQL v14 has new connection statistics in pg_stat_database. In this article, I want to explore one application for them: estimating the correct size for a connection pool. New connection statistics in v14 Commit 960869da080 introduced some new statistics to pg_stat_database: session_time: total time spent by sessions in the database active_time: time […]
PostgreSQL: How to write a trigger
Just like in most databases, in PostgreSQL a trigger is a way to automatically respond to events. Maybe you want to run a function if data is inserted into a table. Maybe you want to audit the deletion of data, or simply respond to some UPDATE statement. That is exactly what a trigger is good […]
PostgreSQL: CREATE STATISTICS – advanced query optimization
PostgreSQL query optimization with CREATE STATISTICS is an important topic. Usually, the PostgreSQL optimizer (query planner) does an excellent job. This is not only true for OLTP but also for data warehousing. However, in some cases the optimizer simply lacks the information to do its job properly. One of these situations has to do with […]
PostgreSQL: ANALYZE and optimizer statistics
Our PostgreSQL 24×7 support team recently received a request from one of our customers who was facing a performance problem. The solution to the problem could be found in the way PostgreSQL handles query optimization (specifically, statistics). So I thought it would be nice to share some of this knowledge with my beloved readers. The […]
“Catchment areas” with PostgreSQL and PostGIS
Recently a colleague in our sales department asked me for a way to partition an area of interest spatially. He wanted to approximate customer potential and optimize our sales strategies respective trips. Furthermore he wanted the resulting regions to be created around international airports first, and then intersected by potential customer locations, in order to […]
Patroni Environment Setup: PostgreSQL High Availability for Windows
PostgreSQL High-Availability has been one of the most dominant topics in the field for a long time. While there are many different approaches out there, Patroni seems to have become one of the most dominant solutions currently in use out there. Many database clusters run on Linux. However, we have seen some demand for a […]
PostgreSQL: What is a checkpoint?
Checkpoints are a core concept in PostgreSQL. However, many people don’t know what they actually are, nor do they understand how to tune checkpoints to reach maximum efficiency. This post will explain both checkpoints and checkpoint tuning, and will hopefully shed some light on these vital database internals. How PostgreSQL writes data Before we talk […]
pg_timetable: asynchronous chain execution
Intro – asynchronous chain execution in pg_timetable I wrote about the new pg_timetable 3 major release not so long ago. Three essential features were highlighted: new session locking implementation; new jackc/pgx Golang library used; exclusive chain execution. Meanwhile, two minor releases have come out, and the current version is v3.2. It focuses on the completely […]