Tag: administration
ERROR: invalid byte sequence – Fix bad encoding in PostgreSQL
(Inscription seen on a T-shirt) It’s annoying to get error messages caused by encoding problems. But it is more annoying not to get error messages and end up with bad data in the database. I’ll show you how to fix bad encoding. Some basic facts about encoding in PostgreSQL Each PostgreSQL database has a server […]
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 […]
PostgreSQL ALTER DEFAULT PRIVILEGES – permissions explained
© Laurenz Albe 2023 Many people have heard that ALTER DEFAULT PRIVILEGES makes it easy to allow other users access to tables. But then, many people don’t understand the command in depth, and I hear frequent complaints that ALTER DEFAULT PRIVILEGES does not work as expected. Read on if you want to know better! Default […]
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 […]
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 […]
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. […]
pgbouncer: Types of PostgreSQL connection pooling
pgbouncer is one of the most widely used tool for connection pooling. At CYBERTEC, we’ve successfully deployed it in many different situations. It has proven to be reliable as well as useful. Before we dive into different pooling modes and their implications, why do we need a connection pooler in the first place? The reason […]
VACUUM does not shrink my PostgreSQL table
Did you ever wonder why VACUUM does not make your PostgreSQL tables smaller? Did you ever wonder why VACUUM does not shrink data files? Well, maybe this is the article you have been looking for. The point is: usually, space is not returned to the operating system after a cleanup and it is important 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 […]
Dealing with streaming replication conflicts in PostgreSQL
© Laurenz Albe 2020 Streaming replication in PostgreSQL is a well-established master-slave replication technique. It is simple to set up, stable and performs well. So many people are surprised when they learn about replication conflicts — after all, the standby server is read-only. This article describes replication conflicts and tells you how to deal with […]
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 […]
A quick pg_stat_statements troubleshooting hack
By Kaarel Moppel How can I use pg_stat_statements for troubleshooting? First, an introductory story (with some slight “drama” added for fun) from those good old days of on-site consulting 🙂 So…I’m at a client where the database is not behaving nicely among other things…what a crappy DB product indeed I hear, it gets cranky every […]