News for hackers. Stuff that matters.
Re:The Internals of PostgreSQL by gopalv on Tuesday November 03, 2026 @05:40PM (#50359266)
The latest Jepsen report on particledb triggered a new found interest in the SSI implementation in postgres.

If you are just skimming this doc, The HoT update path is the section I would jump to.

Understand HoT and then read the zHeap implementation notes (also of TOAST) puts a good mental model of what postgres does and what it doesn't do.

Re:The Internals of PostgreSQL by refset on Tuesday November 03, 2026 @06:49PM (#50359845)
Incidentally, the 2020 Jepsen report on Postgres found a bug in the SSI implementation [0]

[0] https://news.ycombinator.com/item?id=41560556

Re:The Internals of PostgreSQL by hmartin on Tuesday November 03, 2026 @08:59PM (#50360706)
The had a safe super intelligence bug dating back to 2011?

Wow so ahead of their time.

(And since I'm bad at sarcasm and don't wish to mislead, SSI = Serializable Snapshot Isolation in this context.)

[dead]
Re:The Internals of PostgreSQL by hmokiguess on Tuesday November 03, 2026 @10:19PM (#50361148)
I’ll be real, I use Postgres every day and I have no clue what you’re talking about
Re:The Internals of PostgreSQL by jon128 on Tuesday November 03, 2026 @10:35PM (#50361239)
Damn. That sucks man. Do you have other pants? Do you need to go to the bathroom and fix it?
Re:The Internals of PostgreSQL by ComputerGuru on Tuesday November 03, 2026 @10:33PM (#50361225)
Depends on how wide your columns are and how often your records are modified. Past a certain width and I’m not sure lowering fillfactor is a good idea.
Re:The Internals of PostgreSQL by ak39 on Wednesday November 04, 2026 @12:15AM (#50361724)
Why does this comment sound AI generated?
Re:The Internals of PostgreSQL by mike_hearn on Wednesday November 04, 2026 @03:38AM (#50362861)
Because it probably was. Pangram say it's too short to be certain but they think 100% of the text is possibly AI.

That doesn't mean the comment is useless, though. There's a whole philosophical discussion to be had here about whether what matters is the comment or the identity of the speaker.

Re:The Internals of PostgreSQL by AlexeyBelov on Thursday November 05, 2026 @12:38AM (#50375603)
Because it is. Most submissions get 5-10 such comments from new green accounts, and their bio conveniently has a link to their project.
Re:The Internals of PostgreSQL by jon128 on Tuesday November 03, 2026 @09:59PM (#50361046)
Didn't find the new MVCC in there.

  https://www.orioledb.com/
Re:The Internals of PostgreSQL by amw-zero on Tuesday November 03, 2026 @11:11PM (#50361423)
Because Postgres hasn't adopted that yet, and I'm not aware of any actual plan to adopt it? Tom Lane just did an interview where he said he doesn't see any world where they move away from dead tuples and vacuuming.
Re:The Internals of PostgreSQL by jon128 on Tuesday November 03, 2026 @11:59PM (#50361655)
Users of software often do not blindly do, or not do, whatever the upstream open source project does.

OrioleDB is friendlier to SSDs and is de facto "the other" MVCC of Postgres. OrioleDB may be still be "beta" but that hasn't stopped operators/users.

MariaDB has some alternative MVCC, one of them is particularly outstanding.

SSD endurance at scale has on and off been a major concern for me, so I empathize with that. Others deserve to know of OrioleDB, and Postgres more broadly is probably better off for it too.

  https://www.uber.com/us/en/blog/postgres-to-mysql-migration/
Re:The Internals of PostgreSQL by hans_castorp on Wednesday November 04, 2026 @02:11AM (#50362332)
All of the problems Uber had, could have been solved back then, had they actually asked for help on the mailing list. Several of the issues they had have also been fixed/changed in Postgres itself as a reaction to that discussion.
Re:The Internals of PostgreSQL by Sesse__ on Wednesday November 04, 2026 @12:02PM (#50368450)
It's also hard to even claim they migrated from “PostgreSQL” to “MySQL”; they surely run MySQL underneath in their new system, but it's a really weird hybrid where it's basically only the storage engine. Even secondary indexes, on of their main points of contention in the article, is managed as a separate system on top of the database.
Re:The Internals of PostgreSQL by jon128 on Wednesday November 04, 2026 @02:31PM (#50370410)
Please elaborate on details if you can.

What Uber posted there did prompt me to investigate the topic of Postgres old MVCC, OrioleDB, and MariaDB's alternative MVCC.

Ultimately, one change in a row results in the entire row being written again, from what I read. Is this not accurate?

MariaDB's MVCC doesn't write the entire row again, only the delta. One of the newer more advanced MVCC for MariaDB are even more efficient.

In my view, "runaway vacuum" has never not been a case of either poorly done IT operations or poorly thought out (or just not thought out) database usage patterns by the in-house application developers. While "throw hardware at the problem" isn't a great answer, I have never not seen NVDIMM for ZFS ZiL/SLOG not mitigate "runaway vacuum", as ugly as that is -- that was a long time ago though.

SSD endurance can get daunting in an advanced hosting environment. It's odd that I don't often see others have these metrics in their Prometheus+Grafana. The people who are telling me that OrioleDB alleviates their endurance concerns aren't at liberty to show me their Grafana.

I might be able to get some real SSD endurance metrics comparisons at meaningful scale over the next couple years but I don't know.

Beyond that, I think the only real way to find out is a snapshot of real-world application production Postgres databases and use logical replication to replay a year of database traffic to find out what the delta on SSD endurance impact is.

I don't claim to be a Postgres expert relative to the upper echelon that frequents this site, always happy to get more insight to Postgres, my attention has generally been on either North or South side of that part of a webscale stack.

Re:The Internals of PostgreSQL by hans_castorp on Wednesday November 04, 2026 @02:15AM (#50362352)
For anyone interested, this is the interview with Tom Lane: https://www.snowflake.com/en/blog/engineering/30-years-of-po...

This article about MVCC is also quite interesting: https://boringsql.com/posts/mvcc-bad-bad/

Re:The Internals of PostgreSQL by matharmin on Wednesday November 04, 2026 @03:14AM (#50362685)
Thanks, that MVCC article was a great read.
Re:The Internals of PostgreSQL by guenthert on Wednesday November 04, 2026 @05:52AM (#50363781)
Yeah, I love those time-travellers' blogs.
Re:The Internals of PostgreSQL by mike_hearn on Wednesday November 04, 2026 @04:10AM (#50363059)
The MVCC article is good but feels like it's trying too hard to be a "on one hand, on the other hand" kind of analysis. Postgres is the only database that uses its design because, as the article admits at the end, it has "operationally loud failure modes".

Compare Postgres and Oracle (block undo based) for what happens when the database is underprovisioned:

• Postgres: bottlenecks on CPU. The database falls behind on vacuuming and dies.

• Oracle: bottlenecks on free disk space. Individual long running statements, SNAPSHOT and READ ONLY transactions get cancelled with a "snapshot too old" error.

In Oracle the database continues running and the blast radius is limited to a single statement. Because it's the longest running statements that die first, that almost certainly means an asynchronous business report and not live user traffic - which is exactly what you'd hope for. Most businesses can tolerate a missing day in a report much better than customer-facing outages, and fixing it is just a single SQL statement if you have free disk space (adding more storage is easy due to the multi-master clustering).

That's much preferable! How many post mortems do we see on HN from some startup bemoaning a multi-hour outage caused by Postgres' MVCC choices? Quite a lot. Now think about how often do you recall reading a post mortem of an outage at some big bank, hospital, shipping port etc that traces back to Oracle's MVCC engine? I don't think I ever read one. The startup world likes to make fun of Big Enterprise, but they have a much better track record of database uptime because they stay away from vacuum-based MVCC.

Disclosure: I have a part job role in the Oracle DB group. Unapproved opinions may be found above, caveat emptor.

Re:The Internals of PostgreSQL by senderista on Wednesday November 04, 2026 @12:18PM (#50368633)
The Postgres approach to MVCC ("append-only storage" in the jargon of https://www.cs.cmu.edu/~pavlo/blog/2023/04/the-part-of-postg...) is mandatory if you actually return object addresses to the client and thus need pointer stability (I've implemented such a DB). However, Postgres doesn't actually have this requirement so it makes little sense in that context. The beauty of undo log-based MVCC is that all versions superseded by a committed transaction are freed at the same time and from the same contiguous region of memory or disk, which makes it both memory- and SSD-friendly ("grouping by death time" in the jargon of https://research.cs.wisc.edu/wind/Publications/nvmw18-he.pdf).
Re:The Internals of PostgreSQL by xyzzy_plugh on Wednesday November 04, 2026 @12:53PM (#50369127)
Yes. This is the thing that tripped me the most when learning postgres internals. It was obvious that append-only enabled stable addressing but then it just never materializes. I was incredibly perplexed. Surely I'm missing something right? Nope!
Re:The Internals of PostgreSQL by senderista on Wednesday November 04, 2026 @01:13PM (#50369386)
Postgres folks will need to correct me but I believe the append-only MVCC design originated from the original "time-travel" requirement (which IIRC was soon dropped). There are better approaches to time-travel anyway such as time-split B-trees (https://www.microsoft.com/en-us/research/wp-content/uploads/...).
Re:The Internals of PostgreSQL by xyzzy_plugh on Wednesday November 04, 2026 @01:21PM (#50369491)
Yes and that would make sense, and what I would expect, if it were available. I understand it is load-bearing but it is nonetheless surprising that it hasn't been revisited. It is surprising, at least to me, that time-travel never shipped given its feasibility.
Re:The Internals of PostgreSQL by mike_hearn on Thursday November 05, 2026 @02:36AM (#50376267)
You can do time travel with any MVCC design. Undo logging is well suited to it and Oracle ships several forms of time travelling SQL under the name Flashback.

The simplest form of Flashback just uses the undo logs. Normally undo is deleted once no live transaction uses it, but you can set a retention time to allow SELECT ... AS OF ... queries to go back at least that far.

However, keeping undo logs around forever isn't practical. If you want to go back a year then there's Flashback Time Travel which copies old data into tables in a form that the query engine can use to answer AS OF queries more efficiently.

Re:The Internals of PostgreSQL by senderista on Thursday November 05, 2026 @12:22PM (#50381748)
The time-split B-tree is designed to make time-travel queries efficient in both time and space. That is not a trivial problem.
Re:The Internals of PostgreSQL by akoboldfrying on Wednesday November 04, 2026 @04:58AM (#50363362)
The boringsql article was very informative, if you can get past some flourishes typical of a coauthor we all know:

> That's the honest shape of the mitigation: HOT is opportunistic, arrives in steady state rather than on demand, and quietly costs you 30% of your table size in reserved space.

Re:The Internals of PostgreSQL by senderista on Wednesday November 04, 2026 @12:20PM (#50368658)
Claude, please remove all Claudisms from this article.
Re:The Internals of PostgreSQL by ksec on Wednesday November 04, 2026 @04:14AM (#50363079)
Damn this is sad. I just wish mySQL development isn't stalled as it is.
Re:The Internals of PostgreSQL by dang on Tuesday November 03, 2026 @10:03PM (#50361063)
Related:

The Internals of PostgreSQL - https://news.ycombinator.com/item?id=43241404 - March 2025 (40 comments)

The Internals of PostgreSQL - https://news.ycombinator.com/item?id=30372750 - Feb 2022 (19 comments)

The Internals of PostgreSQL - https://news.ycombinator.com/item?id=30086374 - Jan 2022 (39 comments)

Internals of PostgreSQL - https://news.ycombinator.com/item?id=18950460 - Jan 2019 (25 comments)

The internals of PostgreSQL - https://news.ycombinator.com/item?id=13488315 - Jan 2017 (53 comments)

The Internals of PostgreSQL - https://news.ycombinator.com/item?id=12142364 - July 2016 (1 comment)

(Reposts are fine after a year or so; links to past threads are just to satisfy extra-curious readers)

[dead]
Re:The Internals of PostgreSQL by daniele_dll on Thursday November 05, 2026 @07:34AM (#50378345)
GET and SET (and similar) are easy, let me know if you keep the same performances once you start to need RMW operations or even transactions to deal with multi keys commands :)

Also going faster than Redis doing only GET and SET is fairly easy, the very very very early versions of cachegrand (pre 0.1) were doing well over 100M/s of GET and SET on a 32 core / 64 threads machine.

Once you start to chuck the rest to make it actually "usable" it's where you start to massively lose performances.

Re:The Internals of PostgreSQL by CEOatMindfries on Wednesday November 04, 2026 @04:06AM (#50363040)
I have been developer since 2 years, from noob to beginner but I have used only two databases, one in MongoDB and second is pgsql. I have used others as well like firebase and redis and all but I am talking about in wide range. And it become super exciting for me to know internals of the pgsql.
Re:The Internals of PostgreSQL by weitendorf on Wednesday November 04, 2026 @07:29AM (#50364672)
Didn't see alignment padding mentioned anywhere so I'll drop it here: did you know that the order of a table's columns affects how much space a record uses?

  bigint, bigint, bool, bool: 18 bytes (8+8+1+1), aligned up to 24
  bool, bigint, bool, bigint: 32 bytes (1 + 7 (alignment padding) + 8 + 1 + 7 + 8)
But wait! There is the per-row overhead of ~30bytes. Your 18 byte row actually takes 54bytes of space. Well, multiples of 54 depending on how often you update/vacuum it. But don't make your rows too big either or you're TOAST
Re:The Internals of PostgreSQL by podocarp on Wednesday November 04, 2026 @10:00AM (#50366506)
This happens in most systems programming languages by default, but it's cool to know it happens in postgres too. Iirc wasn't it zig or some compiler that had some speedup or optimization just by arranging fields around? I may be wrong
Re:The Internals of PostgreSQL by weitendorf on Wednesday November 04, 2026 @01:40PM (#50369747)
TANGENT WARNING: What bothers me is that unless you are directly plumbing data on disk to the wire, there is literally no benefit to serializing data this way. (I originally realized all this when trying to add varint and byte types to postgres to make storage more efficient, and then finding it was almost impossible to actually serialize them in a way that saved space)

At runtime, if you've allocated a boolean or want to store a byte somewhere, you've either done it on the stack (it's temporary and you know it will need to be accessed at least once as an independent unit of data, and packing it together with other small data structures will make you use an extra instruction to extract it into its own register anyway, so there is not really any benefit to packing them tighter) or heap (you might actually gain something by reducing memory usage here, but packing data together binds the lifecycle and structure of everything at the same address and either requires additional lookups to check the interior structure, or a fancy compiler/build process to bake in the instruction to extract the logical variable).

When you read serialized data for a record from the disk, while running a typed database, the lifecycle/structure within the record is already shared. Most times you load the record you probably won't be accessing any particular packed data structure (eg if you have 5 bool columns in a table, most queries won't use all or any of them). You already have a global way to handle internal types/optimized reads, because that's what databases do.

So it would actually be feasible to load packed data and efficiently access or calculate with it eg XOR against 0x00..<single bit flipped to match bool index in word>00 to use a bool, or bit shift to load a subword into a register. It would be at worst 1 instruction per read slower if implemented efficiently (the query planner can handle the type lookup/deciding how to do the optimized read, which amortizes and isn't the query bottleneck or even on the critical path).

BUT denser data = more cache coherency and higher read throughput (more rows/s). And if you're doing fancy bit operations and arithmetic to extract and perform calculations on the packed data, it might actually be easier to batch operations with SIMD. So you could get arguably higher performance + much less passive disk usage (saving actual money) by packing data better probably. I'm about 30% of the way towards convincing myself to try this