
Too many tables are bad for you
This article shows that problems that too many tables in a single PostgreSQL database can cause and how to deal with these problems.
64 articles by Laurenz Albe.

This article shows that problems that too many tables in a single PostgreSQL database can cause and how to deal with these problems.

This article discusses row-level security, security barrier functions and leakproof functions, which are necessary to make them work.

This article shows the queries that I use to monitor autovacuum and explains the background and the measures you can take to avoid problems.

Read my plea for using the C collation when you create a PostgreSQL database cluster, ideally using the "builtin" collation provider.

Sequence-generated 4-byte integer primary keys can experience integer overflow. I'll show you how to monitor for the problem and fix it.

Two little stories from the working life of the bastard DBA from hell, fighting user problems (but mostly users).

The DESC clause in CREATE INDEX is rarely needed. I'll show use cases for descending indexes, including storage efficiency and performance.

There is no UPDATE ... LIMIT in PostgreSQL. This article shows how to achieve the same result and how to avoid potential pitfalls.

I'll explain how to handle the dreaded error message "database is not accepting commands" and alert you to the responses you should avoid.

This article talks about the new support for converting Roman numerals to numbers in PostgreSQL v18, as well as fun in general.

Learn the concepts of data type alignment and padding bytes in PostgreSQL and how to define your table so that you don't waste storage space.

This article describes the little known parameter stats_fetch_consistency and its potential applications for statistics collection.

This article describes the problem of endless trigger recursion in PostgreSQL and shows how to deal with it and get good performance.

PostgreSQL v17 has been released. If the list of new features does not inspire you, this article will try to change your mind.

Understand why and how to disable memory overcommit to make PostgreSQL run reliably on Linux, including implications for containerization.

This article shows how to use keyset pagination if you want to sort some columns in ascending and others in descending order.

Read about my impressions from the Swiss PGDay 2024 and learn why you should attend PostgreSQL conferences yourself.

This article explains how to examine the PostgreSQL visibility map and showcases performance improvements added in recent releases.

This article describes the possible reasons for a slow COMMIT in PostgreSQL and discusses what you can to against that.

This article explains how to configure syslog logging in PostgreSQL and shows how to view and manage the log with journald.

Do you have a broken foreign key? This article shows possible causes for broken foreign keys, so that you know what to avoid in the future.

Read all there is to know about minor upgrade in PostgreSQL: how, why and when to install them, and what if your software vendor forbids it.

How to model conditional foreign keys: 4 methods to transfer a reference to a polymorphic type to SQL. Explore how PostgreSQL features like JSON support and table inheritance can help.

Find out what PostgreSQL v16 has to offer, what the top new features will be and why the new postgres is so cool and useful.

How to index LIKE conditions in PostgreSQL and Oracle. Answers the question: Why is LIKE indexing simpler in Oracle? Is it better?

Compare the performance of bulk load methods in PostgreSQL. Get recommendations for parameter settings to improve performance even more.

This article discusses how subqueries perform in PostgreSQL and how to rewrite queries to improve their performance.

How to use HOT updates to maintain the row order established by CLUSTER to get efficient index scans in PostgreSQL.

Fix ERROR: invalid byte sequence for encoding - Wrong encoding causes data corruption in PostgreSQL. How to fix bad encoding.

ALTER DEFAULT PRIVILEGES command for PostgreSQL permissions explained: learn how to use it correctly, know its pitfalls and use cases.

This article describes the EXPLAIN option GENERIC_PLAN introduced in PostgreSQL 16, including some examples. Learn about options syntax.

Row locks in PostgreSQL - how do they work? How can I debug problems with them? The answers with examples are here.

This article shows two examples of CHECK constraints that cause problems and explains why PostgreSQL cannot be any more restrictive.

Have you ever seen data corruption from transaction ID wraparound? Avoid PostgreSQL performance problems - read here what causes it.

A cute solution for an unusual request for a unique constraint in PostgreSQL. This blog showcases range data types & exclusion constraints.

This article compares pagination methods for PostgreSQL and their performance. Also, avoid displaying the total result count!

Find out the impact of PostgreSQL column data types on the performance of queries that involve a UNION ALL.

EXPLAIN (ANALYZE, BUFFERS) output is hard to get for a parameterized statement in PostgreSQL. With a few tricks we can get EXPLAIN output.

Improve queries in PostgreSQL - it is not always possible to rewrite OR to UNION in a query. Find out when it is safe to do manually.

Updates getting slower is a frequent complaint of PostgreSQL users. What is behind it and how can I avoid slow updates?

New syntax for SQL functions was introduced in PostgreSQL v14, this article gives you vital tips for this important change & its advantages.

This article shows how surprising transaction anomalies can happen with SELECT FOR UPDATE and what you can to to avoid them.

We discuss the options for case-insensitive comparison and pattern matching in PostgreSQL, comparing the performance of different approaches.

How view permissions are checked, and how that changes if you use the security_invoker view option from PostgreSQL v15. Use row-level security effectively.

This article describes how to cancel queries in PostgreSQL and shows a trick that you can use if canceling a query doesn't work.

Time zone management and timestamp data types in PostgreSQL - learn how to use 'timestamp with time zone' correctly and optimize performance.

Learn how to use DROP ROLE and DROP USER in PostgreSQL. This article explains how to remove users and gives troubleshooting tips.

How do query parameter data types affect performance? Find out how to avoid bad performance by choosing the correct parameter types.

This article shows how pipeline mode, new with PostgreSQL v14, can improve query performance over slow network connections.

This article explains what the entity-attribute-value (EAV) model is and why you shouldn't use it in a relational database.

This article describes how cursors and transactions interact, how WITH HOLD can overcome the limitations, plus some caveats and tricks.

How you can end up with gaps in sequences & how they can even skip backwards. How to build a gapless sequence in PostgreSQL.

This article describes what can go wrong when using the much-loved JSON capabilities of PostgreSQL and gives guidelines how to do it right.

This article describes how PostgreSQL v14 reduces B-tree index bloat with "bottom-up index tuple deletion". A test case shows the difference.

UPDATED July 2023: How to use EXPLAIN ANALYZE in PostgreSQL, learn tools to visualize the output. See query execution time and row count.

This article explains what PostgreSQL tablespaces are, when to use them and how they are different from Oracle tablespaces.

This article shows how you can you use PostgreSQL database statistics to get an upper limit for the correct size for a connection pool.

A shibboleth is a phase whose pronounciation determines if you belong or not. This article tells you how not to pronounce "PostgreSQL".

Replication conflicts can cause problems with streaming replication. This article tells you what they are and how to deal with them.

HOT updates (Heap Only Tuple) boost PostgreSQL DML performance. This article explains the concept, shows examples and gives tuning advice.