I am surprised that "an already-open transaction that reads events for the first time after the swap can see an empty table" is considered acceptable.
I am not a Postgres user, and I appreciate that production databases are complicated beasts. Do people who use Postgres for production think this sounds fine?
Try storing datetimeoffset (ie datetime with time zone) in Postgres. It can’t.
Also suppose you have a lastname and want to have case-insensitive search over it (prefix and equal).
In MS SQL you just add an index. By the way, there is only one type to choose from (ignoring clustered or multicolumn) — it just works.
In Postgres you needed to jump through effing hoops just for that until like 1-2 years ago when they finally added case-insensitive collation with prefix search support.
—
How people ignored such basic stuff for any CRUD app for years is beyond me.
There is a whole feature of postgres and SQL standards called "collations" that I think you may be ignoring here..?
A collation can specialize how comparison and ordering work. In postgres this would also affect the pattern matching operators. I think there have been improvements here over the recent versions, where a "non-deterministic" collation (of which case-insensitivity is an example) is supported by pattern matchers when it wouldn't in older versions.
You can define a column with a custom collation to override the default for the column type. You can also define a domain type with a custom collation, and use that domain for column definitions, so you don't need to set the collation explicitly in every column definition. E.g. you could define a "citext" domain over "text" that adds the case-insensitivity but otherwise stores text.
timestamptz (with time zone) stores the times without time zone (in UTC), on the rationale that 'with time zone' means each read/write of that column will have a user supplied time zone..
Oddly enough, the offset isn't even enough information to truly describe the time zone. There might be a few different time zones that would have the same offset at a certain point in time. So the offset doesn't effectively communicate where the user is, what schedule (if any) they use for DST/summer time, and a bunch of other stuff. I'll admit that "2026-11-29T16:47:27-05:00" makes it pretty likely that the time zone is "America/New_York", but it's far from certain. I suppose it does at least let you do a timezone-aware truncation to a date, but it comes at the cost of making it more tricky to compare values with different offsets.
Timestampz discards the timezone and converts to utc, meaning it is a destructible operation — you cannot bring back the original.
This may be important in many cases: for example antifraud where you want to store also what was literally on the user’s clock (including timezone) and show it later in reports and what have you
That's a problem only because your data model doesn't take into account how to make user supplied datetime work. Timestamp and the likes are not for user supplied data, datetime is. And if you are going to deal with it, you should store two dates: what the user said and what the datetime in utc is at the moment of recording. That gives you everything you will ever need: comparison between timezones, offsets regardless of timezones and a coherent user presentation.
Any solution that does not capture the timezone will be wrong sometimes. Your described solution falls on its face for any situation where an offset doesn't uniquely identify the timezone. For example, Arizona does not recognize daylight savings time, so sometimes it's got the same offset as Mountain Time, other times it has the same offset as Pacific Time.
Like I’ve said with an example of prefix case-insensitive search, some things like ms sql are user-friendly and down to earth problems, and others have excuses "you are holding it wrong".
And? I'm questioning your data model, same problem will happen no matter your database, because now you have to consider DST and comparisons between timezones that are timezone sensitive. Meanwhile storing UTC and as user supplied it both gives you the most flexibility for any representation of date time that your application might need. Not counting that now you are shackled to a vendor like the sibling comment notes, because it's not standard sql
Congratulations. MSSQL has some good features. Its cost, administrative overhead, and lack of available source make it an unacceptable option for a lot of people. Postgres also has lots of features that MSSQL does not have. Not sure why any of this is relevant in a post about differences in the new PG version.
> I agree that the MSSQL timezoneoffset approach is the best.
It is not. A static offset is largely equivalent to a utc timestamp, and thus useless for any consideration of future event.
If you’re concerned about the limited historical and auditing value, it’s not exactly difficult to just tack that information on in a second column, or create a custom type which you can even call datetimeoffset but hanging the entire thing on that edge case is nonsense.
Hell, if you’re concerned about auditing events or fraud control you want a ton more data than just a timezone offset advertised by the client, and storing an entire timestamp just to keep that datum around is an unnecessary waste.
> A static offset however is not equivalent to storing as utc. Storing the local offset is objectively more information than not.
From a datetime manipulation perspective it makes no difference, both are instants and nothing more. Hence my very specific use of “largely equivalent” and further qualification, rather than calling them identical.
A static offset is information in the same sense storing a traceability report for every number is information: it’s metadata, and in most cases it’s closer to hoarding than anything useful.
>> From a datetime manipulation perspective it makes no difference, both are instants and nothing more
True, but they are instants that include local time zone information.
For example, in a town straddling a time zone boundary its useful to know what time is where.
The MSSQL approach is better because it explicitly contains what it says; timestamp with time zone. Postgres explicitly does not store the time zone, preferring instead to store utc time.
The work around is simple, but postgres objectively stores less information.
> For example, in a town straddling a time zone boundary its useful to know what time is where.
A timezone offset does not even remotely come close to a where, and informational inference by proxy is unreliable at best. If you want to know what time is where, you store the where.
> The MSSQL approach is better because it explicitly contains what it says; timestamp with time zone.
It does not contain a timezone. I was going to say that in fairness it does not say it stores a time zone based on its name, but the documentation does say that, so the MSSQL approach is not better, it’s equally useless and misleading.
> postgres objectively stores less information.
Storing generally useless information is hoarding. You could store the full provenance of every number in a program alongside that number, it would be “objectively more information”, in almost every case it would also be a worthless waste of resources, and objectively lead to a worse system.
I understand it is not a standard, but these types are very common in programming languages. If need to jump through hoops to store your data (ORM), this is not user-friendly, that's all.
If it stores them in UTC, doesn't it store them with timezone? Whether what this timezone is is implied or not, there's a specific fixed timezone expected to be found in that column: UTC.
>Time zones can change relative to UTC, e.g. the country Georgia in Europe.
Yeah, but if you have the UTC time, you can calculate any local time at any point, using a tz lookup table of changes (since changes are not deterministic), right?
But the timestamps are not time zone aware! It's just a query-time wrapper around a UTC timestamp, defaulting to input/output using the current session's default time zone.
This makes it a giant footgun in practice, because it might seem to work at first glance. Until you discover that it is completely unfit for purpose in any kind of tz-aware application and returning garbage.
"Timestamp with time zone" should not exist. It should've been an explicit UTC-zoned type, without any kind of automatic conversion.
> Until you discover that it is completely unfit for purpose in any kind of tz-aware application and returning garbage.
IME SQL standard should have been all DATETIME and TIMESTAMP are with TZ, in the sense that they aren't relative at the time they're stored.
Now the absence of DatetimeOffset has never burned me in practice because I've never needed to know the historical offset, only the point in absolute time. And historical offsets can be derived from other sources since zones don't change often enough to justify duplicating that data in every historical value involving time.
Would you include a report that opens its transaction before REPACK and first reads the table after the swap? That would tell me if the snapshot edge matters to this app.
From an app dev perspective, 19 feels pretty quiet—especially since SQL/PGQ and GROUP BY ALL got pushed out to 20.
For ops, though, it's a huge quality-of-life release. Built-in REPACK (CONCURRENTLY), turning on logical replication without a restart, and turning JIT off by default finally fix some of the biggest day-to-day operational headaches without needing external extensions or workarounds.
The JIT default was terrible, I'm very surprised it survived that long. I really like Postgres, but that was the one rare misstep I've noticed.
The JIT just hits so hard when it misfires, suddenly queries that took 100-200ms take 2 seconds because they hit the JIT threshold. And I've seen worse than that for more complex, but still usually fast queries.
Ahh, in chapter 30 of the Postgres docs they explain. The are using LLVM. If I recall correctly, then Chrome V8 and JVM explicitly use very different compiler designs, because GCC and LLVM make many trade-offs the other way than what you would want for JIT.
Why didn’t postgres try plv8 for jit, instead? Only half-joking. It is designed for JIT way more than raw LLVM is.
I can always tell when a new postgres comes out because one of my docker powered apps just breaks (just a selfhosted one, nothing actually important). The official docker for postgres attempts to do no auto update between versions and you're basically left to go figure it out yourself when `latest` breaks itself. This is by design, apparently.
I know there's an argument for version pinning, but I don't want to have to handhold random docker containers. It should be automated IMO. It's become a deterrent for me wanting to deploy anything that depends on postgres.
There is no universe where a database auto- updating across major versions is a sane default. If you want a "postgres-yolo" container, you could build it on top of the upstream image and use cron/github action/etc to automate rebuilds.
Supporting people who think "postgres-yolo" should be a thing would be a masochistic self-own. Perpetual backwards compatibility is not a reasonable addition to all the other constraints that database development must satisfy.
That's comparing apples and oranges. Only a vanishingly small number of SQLite instances are administered by DBAs, therefore the file format has to remain stable. Also, Sqlite3 has no ambition to introduce a massive number of new features, to scale to the skys (though it is surprisingly good in that regard), and prioritizes stability and simplicity.
SQLite also lives in the same operating system process as the application. It has many important use-cases.
Postgres and other databases like it are purposefully outside of the lifetime of a single executable call. They can run for the entire lifetime of a business.
Yes, and this is a tool you need to run yourself when migrating between major versions.
The discussion was started by someone YOLOing their service by using something like "postgres:latest" docker image (I assume), and complaining that it breaks when major version changes.
The times when pgautoupgrade goes wrong are rare, and they've mostly turned out to be ~99% upgrade scripting related, the containers being used in an unusual way, or unusual PostgreSQL extensions that need special treatment which we haven't yet taken into account.
ie Bitnami containers turned out to do weird things, and it took a while to get the pgautoupgrade scripting to play well with them.
The PostgreSQL 17 → 18 on disk layout change by Docker Inc's "postgres" team also caused significant problems, as they were warned it would. But they did it anyway. :(
The pg_upgrade utility which it uses, which comes with PostgreSQL itself, has been very solid.
> There is no universe where a database auto- updating across major versions is a sane default.
And yet, whether it is due to work from distro maintainers or due to slower pace of development from Oracle, I just have never had a serious upgrade problem on MySQL deployments. I am sure they exist, but for a casual user MySQL upgrades seem to break never and Postgres breaks every update. Guess which one I choose?
Needs an option that pre-compresses to zero Bytes on rainy Tuesday's in timezones with a something-and-a-half hours offset from UTC during DST and a race condition in a chron job.
Being on 'latest' instead of a fixed version (at least the major number) is crazy but I agree that the official image not being able to upgrade the data is very inconvenient.
Allowing auto-updating through an env var or something would be appreciated.
I am not a Postgres user, and I appreciate that production databases are complicated beasts. Do people who use Postgres for production think this sounds fine?
reply