If you have something interesting to day about PostgreSQL, we [would love to get a proposal from you]. Even if you have never spoken before, consider responding to the CfP! PgDay 2020 is particularly friendly to first-time and inexperienced speakers. You’re among friends! If you use PostgreSQL, you almost certainly have opinions and experiences that […]
Read More
The very first PgDay San Francisco is coming to the Swedish-American Hall on January 21, 2020. It’s going to be an amazing event. If you have something to say about PostgreSQL… … the Call for Proposals is now open through November 22, 2019. We are looking for 40 minute talks about anything related to PostgreSQL. […]
Read More
The slides from my presentation at PGDay Nordic 2019 are now available.
Read More
A feature of PostgreSQL that most people don’t even know exists is the ability to export and import transaction snapshots. The documentation is accurate, but it doesn’t really describe why one might want to do such a thing. First, what is a “snapshot”? You can think of a snapshot as the current set of committed […]
Read More
PostgreSQL has two autovacuum-age related settings, autovacuum_freeze_max_age, and vacuum_freeze_table_age. Both of them are in terms of the transaction “age” of a table: That is, how long it has been since the table has been scanned completely for “old” tuples that can be marked as “frozen” (a “frozen” tuple is one that no open transaction can […]
Read More
"Breaking PostgreSQL at Scale" at FOSDEM 2019.
Read More
Upon occasion, you want to get the current value of all the sequences in the database. For example, you may have fields that are integer rather than bigint, and you’re concerned how close you are to overflowing one of them (since sequences are bigint and will happily crash through the size of a 32-bit integer). […]
Read More
The slides from my presentation, Securing PostgreSQL at PDXPUG PostgreSQL Day 2018 are now available.
Read More
In addition to the familiar text types VARCHAR and TEXT, PostgreSQL has a type CHAR. It’s little used… and that’s for a reason. It has some very unusual behaviors, which can be quite a surprise if you are not expecting them. First, CHAR is a fixed-width type. When character data is stored in it, it’s […]
Read More
It’s not uncommon that an application needs to serialize access to one or more resources. The temptation is very high to use the LOCK TABLE SQL statement to do this. Resist the temptation. There are many issues with using LOCK: It blocks autovacuum, which can cause bloat or even transaction ID wraparound in extreme cases. […]
Read More
pg_rewind is a utility included with PostgreSQL since 9.x. It’s used to “rewind” a server so that it can be attached as a secondary to a primary. The server being rewound could be the former primary of the new primary, or a secondary that was a peer of the new primary. In pg_rewind terminology, and […]
Read More
PostgreSQL has a variety of ways of telling time: now(), statement_timestamp(), and clock_timestamp(). Each has a different sense of when “now” is: now() is the time at the start of the transaction; it never changes while the current transaction is open. statement_timestamp() is the time that the current statement started running. It changes from statement […]
Read More
(This is another intermittent series of small things that are easy to forget, and cause irritation in the PostgreSQL world…) Since version 1.7, pgbouncer has had built-in TLS support. This is very handy, since the previous versions required stunnel or something similar to provide TLS. Frequently, either for test purposes or because you’re in an […]
Read More
pg_rewind, introduced in PostgreSQL 9.5, is a powerful utility solving a particular problem: If you have a promoted a streaming replication secondary into being a primary, how can you make sure that the former primary, and any other secondaries that used to be connected to it, are able to connect to the new primary? Previously, […]
Read More
Google recently released a tool to check on-disk checksums in PostgreSQL. PostgreSQL being hot, and Google being Google, this generated a lot of press, much of it containing an element of FUD about the integrity of PostgreSQL backups (note that Google’s own announcements were quite straight-forward about it). First, some background: Since PostgreSQL 9.3, it […]
Read More
(This is another intermittent series of small things that are easy to forget, and cause irritation in the PostgreSQL world…) When setting up pgpool2, it’s common to tweak the configuration file repeatedly… and often get a hostname wrong. One common occurrence is then: You fix the hostnames. You restart pgpool2. It refuses to connect to […]
Read More
The slides from my talk on PostgreSQL Replication at PerconaLive 2018 are available.
Read More
(An intermittent series on PostgreSQL parameters whose default settings you should change.) wal_level = logical wal_level controls how much information is written into the write-ahead log. Higher settings write more information, enabling more features, at the expense of (somewhat) larger write-ahead log volume. Just set it to logical, the highest setting. The incremental volume is […]
Read More
(An intermittent series on PostgreSQL parameters whose default settings you should change.) Here’s my preferred logging configuration: log_destination = 'csvlog' logging_collector = on log_directory = '/var/log/postgresql' log_filename = 'postgresql-%Y%m%d-%H%M%S.log' log_rotation_size = 1GB log_rotation_age = 1d log_min_duration_statement = 250ms log_checkpoints = on log_connections = on log_disconnections = on log_lock_waits = on log_statement = 'ddl' log_temp_files = […]
Read More
(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 a server […]
Read More
(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 […]
Read More
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 […]
Read More
The slides from my talk at Nordic PGDay, Why PostgreSQL is Terrible, are now available.
Read More
So many types of replication, so little time! What kind of PostgreSQL replication should you use?
Read More
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… BEGIN; UPDATE table SET money=money+100000; COMMIT; -- And you get an error that the server has disconnected Did that transaction commit, or didn’t it? You don’t really know, because you […]
Read More