· 1 min read

Change these: Logging

(An intermittent series on PostgreSQL parameters whose default settings you should change.)

Here’s my preferred logging configuration:

1log_destination = 'csvlog'
2logging_collector = on
3log_directory = '/var/log/postgresql'
4log_filename = 'postgresql-%Y%m%d-%H%M%S.log'
5log_rotation_size = 1GB
6log_rotation_age = 1d
7log_min_duration_statement = 250ms
8log_checkpoints = on

1 comment

· 1 min read

Change these: archive_mode and archive_command

(An intermittent series on PostgreSQL parameters whose default settings you should change.)

By default archive_mode is set to off, and thus archive_command is ignored. Even if you are not going to be using WAL archiving, you should change these. You can use settings such as:

archive_mode = on
archive_command = '/bin/true'

It requires

2 comments

· 1 min read

Change This: wal_compression

(An intermittent series on PostgreSQL parameters whose default settings you should change.)

Introduced in PostgreSQL 9.5, wal_compression is off by default, but you should probably turn it on.

First, what does it do? The documentation helpfully explains:

When this parameter is on, the PostgreSQL server compresses a full page image written to WAL when full_page_writes is

1 comment

· 2 min read

Mountpoints and the Single PostgreSQL Server

Ultimately, a PostgreSQL database is just files, and those files have to be stored somewhere. Absent tablespaces, they are all stored in a single directory structure, traditionally called PGDATA. While smaller instllations can just use the defaults associated with the packaging, larger databases are often installed on their own volume with its own mountpoint.

Two rules to keep in

0 comments

· 1 min read

Why PostgreSQL is Terrible? at Nordic PGDay

The slides from my talk at Nordic PGDay, Why PostgreSQL is Terrible, are now available.

2 comments

· 3 min read

A Replication Cheat-Sheet

So many types of replication, so little time! What kind of PostgreSQL replication should you use?

I want a standby server to take over if the primary fails.

Use streaming replication.

I want to do read-only queries for load balancing.

Use streaming replication, but be aware that the replica receiving the queries may fall

11 comments

· 1 min read

Commitment Issues

One of the essentials of any database system is that a transaction is either in progress, committed, or rolled back. But consider what happens if…

1BEGIN;
2UPDATE table SET money=money+100000;
3COMMIT;
4-- And you get an error that the server has disconnected

Did that transaction commit, or didn’t it? You

0 comments

· 3 min read

Streaming replication stopped? One more thing to check.

We recently were asked by a client to look at a strange replication situation. Replication had simply stopped from a primary to a streaming replication secondary. Everything looked fine:

  • The secondary was connected to the primary, as we could see in pg_stat_replication.
  • The secondary was not receiving any queries, so delays in applying incoming page changes

1 comment

· 1 min read

"Humans do not have a primary key" at PGConf.EU

0 comments

· 1 min read

"Humans do not have a primary key" at PGOpen SV

I’ll be presenting “Humans do not have a primary key” at PGOpen SV today. Two links from the presentation are:

0 comments