Autovacuum "queue" and progress
Monitor and manage autovacuum queue, understand worker activity and vacuum progress
Monitor and manage autovacuum queue, understand worker activity and vacuum progress
UPDATE 2025: Starting with Postgres 18, the `BUFFERS` option becomes default in `EXPLAIN ANALYZE`, which is great news.
In Postgres, all tables have hidden, system columns; ctid being one of them.
Adding CHECK constraints can be helpful to:
Adding a foreign key (FK) is straightforward:
If you need to change ownership of all database objects in the current database, use this anonymous DO block (or copy-paste from here):
In some cases, it might be beneficial to convert an existing regular asynchronous physical replica to logical, or to create a new physical replica first, and…
Detect, measure, and eliminate table and index bloat to maintain database health
"Slow" is a relative concept. In some cases, we might be happy with query latency 1 minute (or no?), while in other scenarios, even 1 ms might seem to be too…
When connected to a primary (or standby leader in case of cascaded replication), one can use pg_stat_replication:
Assume we have a 10 TiB table created many years ago, partitioned or not, like this one:
Modern ORMs like Rails or Django use int8 (bigint) primary keys (PKs) today.
Does the column order matter in Postgres, storage-wise?
For experiments, it is important to take into account the state of caches – Postgres buffer pool (size of which is controlled by shared_buffers) and OS page…
Today we have quite entertaining material, but knowing (and avoiding) these things can save you time and effort.
## Source CSV we'll be using as an example
PL/Python is a procedural language extension for PostgreSQL that allows you to write stored procedures and triggers in Python, a widely-used, high-level, and…
For query optimization goals – running EXPLAIN (ANALYZE, BUFFERS) and verifying various optimization ideas such as a new index – it is crucial to ensure that…
Previously, we discussed how to implement monitoring for the risks of XID (transaction ID) and MultiXID wraparound.
Here is how you can quickly check data type and size of a value, without looking in the documentation.
Sometimes we need to reindex many indexes – or all of them – and want to do it faster.
Redefining a PK (primary key) is not a difficult procedure, yet it requires a few non-trivial steps to be done.
Removing a foreign key (FK) is straightforward:
Learn how to how to run analyze (to collect statistics)
application_name is useful to control what you and others are going to see in pg_stat_activity (it has a column with the same name), and various tools that…
If you need to load a lot of data, here are the tips that can help you do it faster.
Directory $PGDATA/pg_wal contains WAL files. WAL (Write-Ahead Log) is a core mechanism used for backups, recovery, and both physical and logical replication.
Learn how to troubleshoot streaming replication lag
work_mem is used for sorting and hashing operations during query execution.
In day 60, we discussed how to add a column and that under load you need low lock_timeout and retries (also see: Zero-downtime Postgres schema migrations need…
Implement RAG (Retrieval-Augmented Generation) semantic search and GPT chat directly inside Postgres using pgvector, PL/Python, and OpenAI APIs.
Today – a few tips on using `pg_restore` to restore databases (or only parts of them) from dumps.
As of PG16 (year 2023), Postgres implements UUID versions from 1 to 5, based on RFC 4122.
When conducting a Postgres benchmark (see How to benchmark), quite often we need to run multiple benchmark iterations on the same setup.
The file ~/.psqlrc can be used to set some settings by default. For example: