Month: May 2021
How to interpret PostgreSQL EXPLAIN ANALYZE output
© Laurenz Albe 2021 UPDATED July 2023: EXPLAIN ANALYZE is the key to optimizing SQL statements in PostgreSQL. This article does not attempt to explain everything there is to it. Rather, I want to give you a brief introduction, explain what to look for and show you some helpful tools to visualize the output. Also, […]
PostgreSQL: Bulk loading huge amounts of data
Bulk loading is the quickest way to import large amounts of data into a PostgreSQL database. There are various ways to facilitate large-scale imports, and many different ways to scale are also available. This post will show you how to use some of these tricks, and explain how fast importing works. You can use this […]
UUID, serial or identity columns for PostgreSQL auto-generated primary keys?
© Laurenz Albe 2021 UPDATED 14.05.2022: Sometimes customers ask me about the best choice for auto-generated primary keys. In this article, I’ll explore the options and give recommendations. Why auto-generated primary keys? Every table needs a primary key. In a relational database, it is important to be able to identify an individual table row. If […]
PostgreSQL: Detecting slow queries quickly
UPDATED March 2023: In this post, we’ll focus our attention on PostgreSQL performance and detecting slow queries. Performance tuning does not only mean adjusting postgresql.conf properly, or making sure that your kernel parameters are properly tuned. Performance tuning also implies that you need to first find performance bottlenecks, isolate slow queries and understand what the […]
Setting up PostgreSQL streaming replication
There are two types of replication available in PostgreSQL at the moment: Streaming replication & Logical replication. If you are looking to set up streaming replication for PostgreSQL 13, this is the page you have been looking for. This tutorial will show you how to configure PostgreSQL replication and how to set up your database servers […]
Publishing maps with Geoserver and PostGIS
Analysing data within PostGIS is just one side of the coin. What about publishing our datasets as maps that various clients can consume and profit from? Let’s have a look at how this can be accomplished with Geoserver. Geoserver acts in this regard as a full-fledged open source mapping server, supporting several OGC compliant services, […]
Terminating database connections in PostgreSQL
In PostgreSQL, every database connection is a server-side process. This makes PostgreSQL a robust multi-process rather than a multi-threaded solution. However, occasionally people want to terminate database connections. Maybe something has gone wrong, maybe some kind of query is taking too long, or maybe there is a maintenance window approaching. In this blog you will […]