PostgreSQL 18 update for self-hosters

The Literate Computing dashboard has successfully upgraded two standalone and one two-container sites without incident. Mostly all that was required was changing the target Postgres version in a variable, so as advertised, the process is the same as the last several.

It’s actually pretty supported, it’s much safer than upgrading a database major version. If something goes wrong, you just don’t switch over to the new server. If you are close to needing an OS upgrade and/or want minimal downtime it’s a good way to go. You have read-only while you build the new server and then switch to it. The easy way you have just downtime for the final rebuild, or zero downtime if you copy the certs from the old server).

If everything goes wrong with a DB upgrade, building a new server and restoring the backup is the easy solution.

Do make sure to make a backup before starting. I do a database-only backup since you’re not going to lose your uploads.

4 לייקים

NOTE: Not sure the reason, but the PostgreSQL 18 upgrade disables the native data checksums. PostgreSQL data checksums a default feature and it seems very unusual to disable them.

PR to not disable data checkums (enabled by default): Do not disable PostgreSQL 18 data checksums - Pull Request #1105 - discourse/discourse_docker - GitHub

And it’s better than having to have 20GB free for the 1 hour you need it in one year lol

Perhaps this should be the recommended approach in order to save trees and water. :sweat_smile:

Just to confirm, I’m not using PostgreSQL provided by Discourse and Discourse itself does not require PG18 yet, right? So I am not (yet) required to upgrade to PG18.

Good point. But the other one is that LTS releases come every couple of years, so it’s not a bad idea to go ahead and do that at the same time.

You definitely have a while. They pushed for . . . uh, some release pretty quickly after the update because of some feature that was required, but you can likely wait as long as a year. I watch the discourse_docker repo. At some point they’ll start talking about removing support for PG15; it’s not especially noisy and is an easy way to keep up with updates to interal stuff.

2 לייקים

Worked fine on my Pi 5 install, two rebuilds and done.

6 לייקים

Do we have any benchmarks btw?

This might encourage others to follow in our intrepid footsteps sooner.

My free web search AI is telling me:

For a typical Rails app, moving from PostgreSQL 15 → 18 can yield ~10–25% faster query performance with no code changes, and up to 40% in specific query patterns if you take advantage of new indexing and planner features.

If true, that’s quite an upgrade! :tada:

5 לייקים