PostgreSQL Tips: Performance, Indexes, Maintenance and AI Search

The tips in this collection show how to make PostgreSQL faster, how to maintain it cleanly and how to use it for new tasks. Each post explains one topic from operations and the steps you take to apply it yourself. The post on backups is in English; the others are in German and marked "(German)".

For speed there are two posts. PostgreSQL Performance Settings (German) gives an overview of the settings that matter for performance. Enabling PostgreSQL HugePages (German) leads from shared_buffers through vm.nr_hugepages to THP, with verification and a way back. For maintenance of the database, Optimising PostgreSQL Indexes (German) explains how to find unused and duplicate indexes. You also measure bloat there. PostgreSQL Maintenance — VACUUM, REINDEX, CLUSTER (German) shows when you need which, and how to tune autovacuum.

For safety, Back Up a PostgreSQL Cluster: pg_dump, pg_dumpall and Restore explains logical backups of a whole cluster, restoring a single database and the limits of dumps.

More posts: pgvector: AI Search Directly in PostgreSQL (German) explains vector search, embeddings and RAG (AI answers based on your own documents) without a second database. PostgreSQL Compared (German) sets PostgreSQL against Oracle, SQL Server, MySQL and Db2. Millions of SEC Filings in PostgreSQL (German) describes the architecture of a financial data platform from a technical point of view.

If you want to go deeper with guidance, attend PostgreSQL Performance Tuning (German) or PostgreSQL Administration (German).

Frequently Asked Questions (FAQ)

Where do I start when PostgreSQL is slow?

Start with the overview in PostgreSQL Performance Settings. After that, the posts on index maintenance and HugePages are worth reading. How you check the effect of a change is explained in each post.

When do I need VACUUM, REINDEX or CLUSTER?

The post PostgreSQL Maintenance explains when you need which command, what the parameters mean, which commands lock the table and which run online. It also shows how to tune autovacuum.

Do I need a second database for AI search?

Not necessarily. The post pgvector: AI Search Directly in PostgreSQL shows what pgvector can do, when it pays off and when it does not.

How do I back up a whole PostgreSQL cluster?

Back up every database with pg_dump and the roles and tablespaces with pg_dumpall --globals-only. The post on cluster backups shows a script for all databases, the restore of a single database and the limits of logical dumps.