NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
▲What Changes When You Upgrade from PostgreSQL 18 to 19 (rishigoomar.com)
gwking 1 days ago [-]
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?

paulryanrogers 1 days ago [-]
IIRC it depends upon transaction isolation level, and every mode has its trade-offs
cwillu 1 days ago [-]
No, this specific deficiency applies in all isolation modes, and is therefore probably the main reason why that behaviour is not the default.
1 days ago [-]
piskov 1 days ago [-]
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.

skew-aberration 1 days ago [-]
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..
dmatech 9 hours ago [-]
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.
piskov 1 days ago [-]
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

braiamp 18 hours ago [-]
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.
piskov 15 hours ago [-]
Dude, you literally have datetimeoffset in ms sql
paulryanrogers 15 hours ago [-]
That's not SQL standard. Pg can provide similar functionality with custom types and functions, if it must be a single assignment and output.
piskov 15 hours ago [-]
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".
braiamp 7 hours ago [-]
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
skywhopper 12 hours ago [-]
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.
bruce511 1 days ago [-]
I agree that the MSSQL timezoneoffset approach is the best.

However the Postgres (and others) work-around is simply to add a LocalTimeZone field where necessary.

Yeah, it's not as convenient, but it's a simple, effective, work-around.

For me, this isn't the killer-app distinction that suggests choosing MSSQL over Postgres.

masklinn 23 hours ago [-]
> 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.

bruce511 17 hours ago [-]
Yes, the work-around is simple (as I said above.)

A static offset however is not equivalent to storing as utc. Storing the local offset is objectively more information than not.

But yes, the workaround is simple.

masklinn 34 minutes ago [-]
> 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.

piskov 15 hours ago [-]
You may have a lot of dates. And thus would need a lot of “second” columns.
masklinn 32 minutes ago [-]
Ok?
dapperdrake 1 days ago [-]
This kind of audit trail sounds like a "store a string" nail or hammer.
crote 19 hours ago [-]
Even worse: your future timestamps will be corrupted if the timezone definition ever changes!

Your country abolishes DST? Good luck trying to fix that mess...

piskov 15 hours ago [-]
Imagine some kind of assessment system (like tests / questionnaires); the only relevant “time” is during that assessment.

You would not need to convert that time to some other time zone and what have you 3 years from now.

For other stuff, of course, utc is enough.

However it is just huge amount of cope trying to defend that you cannot store what ms sql allows you to.

paulryanrogers 15 hours ago [-]
Pg can store it, either as an extra column or a custom type. DatetimeOffset isn't in the standard, which I think speaks to how niche the need is.
piskov 14 hours ago [-]
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.
masklinn 31 minutes ago [-]
> these types are very common in programming languages

Mostly out of legacy mistakes in datetime handling.

coldtea 12 hours ago [-]
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.
dapperdrake 8 hours ago [-]
Sadly, no.

Time zones can change relative to UTC, e.g. the country Georgia in Europe.

Daylight savings time (DST) can affect the offset from UTC as well and can vary based on location and can vary across UTC for the same location.

coldtea 7 hours ago [-]
>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?

jiggawatts 1 days ago [-]
Conversely, MS SQL doesn’t allow BRIN indexes for clustered row-store tables despite already having the code in the database engine for it!

Every database engine has bizarre limitations that make no sense to me.

I’ve noticed that a few other disgruntled DBAs have started fixing these issues up by throwing tokens at Postgres.

paulddraper 11 hours ago [-]
> Try storing datetimeoffset

Datetime+offset is virtually never useful to store. Almost always a mistake or at best unnecessary.

You can use a composite type if you really want to, but it’s such a niche case I’m not surprised there’s not a dedicated feature.

> case-insensitive search over it (prefix and equal).

Has worked for decades, since 2003.

  CREATE INDEX ON person (lower(last_name) text_patten_ops);

  SELECT *
  FROM person
  WHERE lower(last_name) LIKE ‘smi%’;
piskov 8 hours ago [-]
> as worked for decades, since 2003.

My man, suppose you use an ORM. With your approach you must not forget to:

1. Lower the column

2. Lower the search term

… every single time you write a query.

And god forbid you fuck this up even once. This is not how reliable systems are done

sarajevo 1 days ago [-]
Fair points about SQL Server’s convenence, but Postgres has supported time zone aware timestamps and indexed case insensitive searches for decades…

The original offset requires separate storage, and indexing requires a little more explicit configuration.

I’d characterize these as design tradeoffs rather than missing CRUD functionality.

crote 18 hours ago [-]
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.

paulryanrogers 15 hours ago [-]
> 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.

piskov 6 hours ago [-]
> indexed case insensitive searches for decades…

Which is …? And prefix support is important (eg first few letters of a last name)

piskov 15 hours ago [-]
Timestamp with timezone should be in top-5 the most misleading names ever
whoElseButUmar 16 hours ago [-]
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.
yuuch 3 days ago [-]
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.

fabian2k 1 days ago [-]
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.

dapperdrake 1 days ago [-]
That sounds rough.
dapperdrake 1 days ago [-]
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.

https://www.postgresql.org/docs/current/jit-reason.html

dapperdrake 1 days ago [-]
Always thought the stuff that makes people good at data geometry and query planning also makes people good at compilers.

Postgres is a surprising counter-example. Especially, because its overall quality seems rather high. Food for thought.

On the other hand, fsync-gate showed that well-meaning people can end up talking past each other.

Developing Postgres seems harder and harder by the day.

samus 21 hours ago [-]
> Developing Postgres seems harder and harder by the day.

The price of success I'd say. The more success you have the more careful you have to be about rocking the boat.

dapperdrake 15 hours ago [-]
Or spiking query latency by a factor of 10 in production.
JoshTriplett 21 hours ago [-]
Or cranelift.
dapperdrake 15 hours ago [-]
Thank you for suggesting Cranelift.

Has anybody had good experience with ensuring Cranelift uses JIT and not AOT?

seblon 21 hours ago [-]
[dead]
dankobgd 19 hours ago [-]
number goes up
Scaled 1 days ago [-]
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.

TkTech 1 days ago [-]
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.
rectang 1 days ago [-]
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.
hellcow 24 hours ago [-]
> Perpetual backwards compatibility is not a reasonable addition to all the other constraints that database development must satisfy.

sqlite3 has been backwards compatible since its release in 2004.

samus 21 hours ago [-]
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.
dapperdrake 8 hours ago [-]
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.

A third use-case are Excel spreadsheets.

justinclift 23 hours ago [-]
PostgreSQL (over the wire) is backwards compatible for at least a few versions, so it should be "pretty safe" for a lot (most?) situations.
sroussey 23 hours ago [-]
The file format is not safe. Thus the major version.
justinclift 19 hours ago [-]
There's literally a utility, pg_upgrade, that comes with PostgreSQL for doing upgrades:

https://www.postgresql.org/docs/current/pgupgrade.html

Are you saying that can go wrong?

ffaccount2 18 hours ago [-]
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.

justinclift 17 hours ago [-]
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.

dapperdrake 1 days ago [-]
Let’s call it fake SMR as a service.
conradfr 21 hours ago [-]
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.

Defman 1 days ago [-]
If you want to YOLO the latest version with automatic upgrade, consider using [1] instead of the default postgres:latest image

[1]: https://hub.docker.com/r/pgautoupgrade/pgautoupgrade

dapperdrake 1 days ago [-]
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.
hahn-kev 16 hours ago [-]
IMO there shouldn't be a latest tag, it's a trap
dapperdrake 1 days ago [-]
Semver in practice is "a land of contrasts", but when exactly is 'latest' the best possible idea for production postgres?

At that point also go with "ext4" 'latest'. Bonus points for it silently going to ext5 in future.

drewfax 1 days ago [-]
I'm in same boat. I love Postgres but honestly it's backward incompatability is a non starter for self-hosting.
drdexebtjl 1 days ago [-]
You don’t have to upgrade to a new major version when it comes out, you know?

Postgres 18 will still get bug fixes and security updates for 4 more years.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 06:48:24 GMT+0000 (Coordinated Universal Time) with Vercel.