Y
HN HRCB new | past | comments | ask | show | by right | domains | dashboard | about hrcb
+0.11 What is a database transaction? (planetscale.com)
244 points by 0x54MUR41 2 days ago | 63 comments on HN | Mild positive Editorial · vv3.4 · 2026-02-24
Article Heatmap
Preamble: +0.10 — Preamble P Article 1: +0.10 — Freedom, Equality, Brotherhood 1 Article 2: +0.10 — Non-Discrimination 2 Article 3: ND — Life, Liberty, Security Article 3: No Data — Life, Liberty, Security 3 Article 4: ND — No Slavery Article 4: No Data — No Slavery 4 Article 5: ND — No Torture Article 5: No Data — No Torture 5 Article 6: ND — Legal Personhood Article 6: No Data — Legal Personhood 6 Article 7: ND — Equality Before Law Article 7: No Data — Equality Before Law 7 Article 8: ND — Right to Remedy Article 8: No Data — Right to Remedy 8 Article 9: ND — No Arbitrary Detention Article 9: No Data — No Arbitrary Detention 9 Article 10: ND — Fair Hearing Article 10: No Data — Fair Hearing 10 Article 11: ND — Presumption of Innocence Article 11: No Data — Presumption of Innocence 11 Article 12: -0.14 — Privacy 12 Article 13: +0.16 — Freedom of Movement 13 Article 14: +0.10 — Asylum 14 Article 15: +0.10 — Nationality 15 Article 16: ND — Marriage & Family Article 16: No Data — Marriage & Family 16 Article 17: 0.00 — Property 17 Article 18: +0.10 — Freedom of Thought 18 Article 19: +0.26 — Freedom of Expression 19 Article 20: +0.05 — Assembly & Association 20 Article 21: ND — Political Participation Article 21: No Data — Political Participation 21 Article 22: +0.05 — Social Security 22 Article 23: ND — Work & Equal Pay Article 23: No Data — Work & Equal Pay 23 Article 24: ND — Rest & Leisure Article 24: No Data — Rest & Leisure 24 Article 25: ND — Standard of Living Article 25: No Data — Standard of Living 25 Article 26: +0.26 — Education 26 Article 27: +0.16 — Cultural Participation 27 Article 28: +0.08 — Social & International Order 28 Article 29: +0.10 — Duties to Community 29 Article 30: 0.00 — No Destruction of Rights 30
Negative Neutral Positive No Data
Aggregates
Weighted Mean +0.11 Unweighted Mean +0.09
Max +0.26 Article 19 Min -0.14 Article 12
Signal 17 No Data 14
Confidence 23% Volatility 0.09 (Low)
Negative 1 Channels E: 0.6 S: 0.4
SETL +0.11 Editorial-dominant
Evidence: High: 2 Medium: 5 Low: 10 No Data: 14
Theme Radar
Foundation Security Legal Privacy & Movement Personal Expression Economic & Social Cultural Order & Duties Foundation: 0.10 (3 articles) Security: 0.00 (0 articles) Legal: 0.00 (0 articles) Privacy & Movement: 0.06 (4 articles) Personal: 0.05 (2 articles) Expression: 0.15 (2 articles) Economic & Social: 0.05 (1 articles) Cultural: 0.21 (2 articles) Order & Duties: 0.06 (3 articles)
Domain Context Profile
Element Modifier Affects Note
Privacy
No privacy policy accessible from provided content; cannot evaluate on-domain.
Terms of Service
No terms of service accessible from provided content; cannot evaluate on-domain.
Accessibility
No accessibility statement or WCAG compliance information visible in provided content.
Mission
Mission statement not present in provided content; commercial SaaS provider focus visible but insufficient for modifier.
Editorial Code
No editorial code or standards statement visible in provided content.
Ownership
Commercial entity (PlanetScale); ownership structure not disclosed in provided content.
Access Model 0.00
Article 19
Content is publicly accessible without login or payment; blog article freely readable.
Ad/Tracking -0.10
Article 12
Sentry DSN and IMG CDN configuration visible in window.ENV suggests analytics/monitoring; tracking infrastructure present but not intrusive in blog content itself.
HN Discussion 19 top-level comments
rishabhaiover 2026-02-22 13:17 UTC link
It's an absolute pleasure reading planetscale blogs. I'm curious about what tool is used to make these visualizations?
MHordecki 2026-02-22 13:44 UTC link
I’ve found this article lacking. Like some other articles in this space, it introduces isolation levels through the lens of the phenomena described in the SQL standard, but I find that there’s a different, more intuitive approach.

I think it’s more tractable to define this problem space starting from the concept of (strict) serializability, which is really a generalization of the concept of thread safety. Every software engineer has an intuitive understanding of it. Lack of serializability can lead to execution-dependent behavior, which usually results in hard-to-diagnose bugs. Thus, all systems should strive towards serializability, and the database can be a tool in achieving it.

Various non-serializable levels of database transaction isolation are relaxations of the serializability guarantee, where the database no longer enforces the guarantee and it’s up to the database user to ensure it through other means.

The isolation phenomena are a useful tool for visualizing various corner cases of non-serializability, but they are not inherently tied to it. It's possible to achieve serializability while observing all of the SQL phenomena. For example, a Kubernetes cluster with carefully-written controllers can be serializable.

zzzeek 2026-02-22 14:34 UTC link
I think this is a great post to have but I'm going to make a critical usability suggestion:

* the videos should have "pause" and a "step at a time" control *

Even at the "half speed", without a deep knowledge of the context, the videos move way too fast for me to read the syntax that's invoking and line it up with the data on the left side. I (and im definitely not the only one) need to be able to sit on one step and stare at the whole thing without the latent anxiety of the state changing before I've had a chance to grok the whole thing.

this has nothing to do with familiarity with the concepts (read my profile). I literally need time to read all the words and connect them together mentally (ooh, just noticed this is pseudo-SQL syntax also, e.g. "select id=4", that probably added some load for me) without worrying they're going to change before watching things move.

please add a step-at-a-time button!

interlocutor 2026-02-22 14:37 UTC link
A lot of database tools these days prioritize instant sharing of updates over transactions and ACID properties. Example: Airtable. As soon as you update a field the update shows up on your coworkers screen who also has the same table open. The downside of this is that Airtable doesn't do transactions. And the downside of not doing transactions is potentially dangerous data inconsistencies. More about that here: https://visualdb.com/blog/concurrencycontrol/
jascha_eng 2026-02-22 16:20 UTC link
This actually used to be one of my favorite interview questions for backend engineers. Everyone has used transactions but depending on your seniority you'd understand it to different degrees.

And no I'd never expect people to know the isolation levels by heart, but if you know there are different ones and they behave differntly that's pretty good and tells me you are curious about how things work under the hood.

unkulunkulu 2026-02-22 17:13 UTC link
> At this stage, it has nothing to do with xmin and xmax, but rather because other transactions cannot see uncommitted data

Am I missing something or this statement is incomplete? Also I find the visualization of commit weird, it “points to” the header of the table, but then xmax gets updated “behind the scenes”? Isnt xmax/xmin “the mechanism behind how the database knows what is committed/not committed”? Also, there could be subtransactions, which make this statement even more contradictory?

I enjoyed the visualizations and explanations otherwise, thanks!

zadikian 2026-02-22 17:29 UTC link
Seems like a frequent surprise is that Postgres and MySQL don't default to serializable (so not fully I in ACID). They do read-committed. I didn't see this article mention that, but maybe I missed it. The article says read-committed provides "slightly" better performance, but it's been way faster in my experience. Forget where, but I think they said they chose this default for that reason.

Using read-committed ofc means having to keep locking details in mind. Like, UNIQUE doesn't just guard against bad data entry, it can also be necessary for avoiding race conditions. But now that I know, I'd rather do that than take the serializable performance hit, and also have to retry xacts and deal with the other caveats at the bottom of https://www.postgresql.org/docs/current/transaction-iso.html

Quarrelsome 2026-02-22 17:35 UTC link
I have learned about the beauty of predicate locks. That's such a sexy way of dealing with the issue instead of just blithely funneling all writes.
nkzd 2026-02-22 18:12 UTC link
Have you ever seen anyone changing transaction isolation levels in code? I think pessimistic or optimistic locking is preferred way to handle transaction concurrency.
lasgawe 2026-02-22 18:13 UTC link
We built an entire project for a client-side project with millions of SQL rows and thousands of users without adding a single transaction. :/
shalabhc 2026-02-22 18:33 UTC link
For all interested in this topic, I highly recommend the book Designing Data Intensive Applications https://www.goodreads.com/book/show/23463279-designing-data-....

It goes into not only different isolation levels, but also some ambiguity in the traditional ACID definition.

I believe a 2nd edition is imminent.

zabzonk 2026-02-22 19:10 UTC link
I thought this was pretty good, not least because it attempts to explain isolation levels, something I always found pretty tricky when teaching SQL. Mind you, I was only teaching SQL, and so isolation, as part of C and C++ courses so that our clients could do useful stuff, but explaining what levels to use was always tuff.
cryptonector 2026-02-22 21:04 UTC link
In the section about serializable read TFA gets the `accounts` `balance` wrong.
nazwa 2026-02-22 21:18 UTC link
Is it just me, or are the final results of the deadlock visualisations incorrect? In both animations (mysql/pg), the final `SELECT balance from account...` queries appear to show the result of the two sessions, which have been terminated.
chamomeal 2026-02-22 21:29 UTC link
never used planetscale but I’ve always liked their blog, and other content. One of the founders interviewed on the software engineering daily podcast and it was super interesting
bigstrat2003 2026-02-22 23:05 UTC link
A miserable little pile of queries! But enough talk, have at you!
piskov 2026-02-22 23:11 UTC link
> A phantom read is one where a transaction runs the same SELECT multiple times, but sees different results the second time around

> Under the SQL standard, the repeatable read level allows phantom reads, though in Postgres they still aren't possible.

This is bad wording which could lead to an impression that a repeatable read may show different values. Values in rows will be the same but new rows may be added to the second result set. New rows is important as no previously read rows can be either changed or deleted — otherwise there will be no repetition for those rows second time around.

rmunn 2026-02-23 01:27 UTC link
I like to think of transactions, in an MVCC system like Postgres, as being like snapshots in copy-on-write filesystems like btrfs or zfs. When you BEGIN a transaction, the DB takes a snapshot of your data, so now there are two versions of the data, the snapshot (visible to everyone else) and the "private" version visible only to your transaction. Then as you run UPDATEs, the new data is written to the private copy, but everyone else continues to work with the snapshot. (And might be creating their own private copies for other transactions).

If you do a ROLLBACK, then your private copy of the data is discarded, and its changes never make it into the official copy. But if you do a COMMIT, then your private snapshot is made public and is the new, official, copy for everyone else to read from. (Except those who started a transaction before you ran COMMIT: they made their private copies from the older snapshot and don't have a copy of your changes).

This is probably obvious to nearly everyone here, but I figured I'd write it anyway. You never know who might read an analogy like this and have that lightbulb moment where it suddenly makes sense.

P.S. Another analogy would be Git branches, but I'll write that in a different comment.

rmunn 2026-02-23 01:36 UTC link
One way to think about transactions, as I wrote in an earlier comment, would be to think of them as being like snapshots in a copy-on-write filesystem like btrfs or zfs. But another way to think of them is being like Git branches.

When you BEGIN a transaction, you're creating a branch in Git. Everyone else continues to work on the master branch, perhaps making their own branches (transactions) off of it while you're working. Every UPDATE command you run inside the transaction is a commit pushed to your branch. If you do a ROLLBACK, then you're deleting the branch unmerged, and its changes will be discarded without ever ending up in the master branch. But if you instead do a COMMIT, then that's a `git merge` command, and your changes will be merged into the master branch. If they merge cleanly, then all is well. If they do NOT merge cleanly, because someone else merged their own branch (committed their own transaction) that touched the same files that you touched (updated rows in the same table), then the DB will go through the file line by line (go through the table row by row) to try to get a clean merge. If it can successfully merge both changes without conflict, great. If it can't, then what happens depends on the transaction settings you chose. You can, when you start the transaction, tell the DB "If this doesn't merge cleanly, roll it back". Or you can say "If this doesn't merge cleanly, I don't care, just make sure it gets merged and I don't care if the conflict resolution ends up picking the "wrong" value, because for my use case there is no wrong value." This is like using "READ UNCOMMITTED" vs "SERIALIZABLE" transaction settings (isolation levels): you would use "READ UNCOMMITTED" if you don't care about merge conflicts in this particular table, and just want a quick merge. You would use "SERIALIZABLE" for tables with data that must, MUST, be correct, e.g. account balances. And there are two more levels in between for subtle differences in your use case's requirements.

As with my previous comment, this is probably obvious to 98.5% of people here. But maybe it'll help someone get that "ah-ha!" moment and understand transactions better.

Score Breakdown
+0.10
Preamble Preamble
Low P:free_access
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

Preamble values (dignity, equality, peace) not directly addressed. Structural signal: publicly accessible educational content without paywalls supports information accessibility. Minor positive from open knowledge sharing.

+0.10
Article 1 Freedom, Equality, Brotherhood
Low P:equal_access
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

No direct editorial treatment of equality/dignity. Structural: free public access to technical education is mild positive for equal information access.

+0.10
Article 2 Non-Discrimination
Low P:non_discrimination
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

No discrimination addressed in content. Structural: publicly available educational content without access restrictions based on status, origin, or characteristics is mildly positive.

ND
Article 3 Life, Liberty, Security
null

Right to life not addressed; technical database article does not engage with this article.

ND
Article 4 No Slavery
null

Slavery and servitude not addressed; not applicable to technical content.

ND
Article 5 No Torture
null

Torture and cruel treatment not addressed; not applicable to technical content.

ND
Article 6 Legal Personhood
null

Right to recognition before law not addressed; technical article does not engage.

ND
Article 7 Equality Before Law
null

Equal protection before law not addressed; not applicable to technical database documentation.

ND
Article 8 Right to Remedy
null

Effective remedy for human rights violation not addressed; not applicable to technical content.

ND
Article 9 No Arbitrary Detention
null

Arbitrary arrest and detention not addressed; not applicable.

ND
Article 10 Fair Hearing
null

Fair and public hearing not addressed; not applicable to technical article.

ND
Article 11 Presumption of Innocence
null

Presumption of innocence not addressed; not applicable to technical content.

-0.14
Article 12 Privacy
Medium P:privacy_tracking
Editorial
0.00
Structural
-0.10
SETL
+0.10
Combined
ND
Context Modifier
ND

Editorial: no explicit privacy violations mentioned; standard educational content. Structural: Sentry DSN and image CDN tracking infrastructure present in page environment variables; analytics/monitoring systems in use reduce privacy protections. Context modifier: ad_tracking modifier applied. Article 12 right to privacy mildly undermined by observable tracking signals.

+0.16
Article 13 Freedom of Movement
Medium A:freedom_of_movement P:no_restrictions
Editorial
+0.20
Structural
+0.10
SETL
+0.14
Combined
ND
Context Modifier
ND

Editorial: no restrictions on movement or residence mentioned; neutral. Structural: content freely accessible, no geographic blocking evident; open access infrastructure supports freedom of information movement. Mild positive from open architecture.

+0.10
Article 14 Asylum
Low P:asylum_access
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

Article 14 not editorially addressed. Structural: freely accessible content without national/regional discrimination supports information asylum principle. Mild positive from non-restrictive access.

+0.10
Article 15 Nationality
Low P:nationality_neutral
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

Nationality not addressed editorially. Structural: content accessible regardless of nationality supports non-discrimination on this axis.

ND
Article 16 Marriage & Family
null

Marriage and family not addressed; not applicable to technical database article.

0.00
Article 17 Property
Low P:property_neutral
Editorial
ND
Structural
0.00
SETL
ND
Combined
ND
Context Modifier
ND

Right to property not addressed in content. Structural: article discusses data integrity and ownership concepts abstractly; no editorial position on property rights. Neutral.

+0.10
Article 18 Freedom of Thought
Low P:no_restriction
Editorial
ND
Structural
+0.10
SETL
ND
Combined
ND
Context Modifier
ND

Freedom of thought, conscience, religion not addressed editorially. Structural: content accessible to all beliefs/worldviews without filtering supports conscience freedom. Mild positive.

+0.26
Article 19 Freedom of Expression
High A:information_sharing P:free_access F:educational
Editorial
+0.30
Structural
+0.20
SETL
+0.17
Combined
ND
Context Modifier
ND

Editorial: explicit educational mission to share knowledge about database concepts; article is structured as technical instruction freely shared. F: framing as accessible knowledge for 'thousands of applications.' Structural: publicly available, no paywall, no registration required, searchable/indexable content supports information freedom. Combined moderate-mild positive from knowledge dissemination.

+0.05
Article 20 Assembly & Association
Low P:no_forced_association
Editorial
ND
Structural
+0.05
SETL
ND
Combined
ND
Context Modifier
ND

Freedom of association not explicitly addressed. Structural: content accessible without forced account creation, membership, or association requirement; no coercive structure. Very mild positive.

ND
Article 21 Political Participation
null

Political participation not addressed; not applicable to technical blog article.

+0.05
Article 22 Social Security
Low P:public_good
Editorial
ND
Structural
+0.05
SETL
ND
Combined
ND
Context Modifier
ND

Social security not directly addressed. Structural: free technical education supports social and economic development as public good. Minimal positive.

ND
Article 23 Work & Equal Pay
null

Right to work and fair conditions not addressed in technical content.

ND
Article 24 Rest & Leisure
null

Rest and leisure not addressed; not applicable to technical article.

ND
Article 25 Standard of Living
null

Adequate standard of living not addressed; not applicable to database technical documentation.

+0.26
Article 26 Education
High A:education P:accessible_learning F:technical_literacy
Editorial
+0.30
Structural
+0.20
SETL
+0.17
Combined
ND
Context Modifier
ND

Editorial: explicit educational intent; article designed to teach database fundamentals to developers; supports technical literacy and human development. F: framing as foundational knowledge 'fundamental to how SQL databases work.' Structured with progressive complexity (begin with basics, advance to isolation levels). Structural: free, no prerequisites or access barriers; publicly available educational resource. Combined moderate-mild positive from clear educational mission.

+0.16
Article 27 Cultural Participation
Medium A:cultural_knowledge P:shared_culture
Editorial
+0.20
Structural
+0.10
SETL
+0.14
Combined
ND
Context Modifier
ND

Editorial: article shares technical/scientific culture freely; contributes to shared human knowledge base. F: positioned as part of broader database engineering culture. Structural: publicly available contribution to common technical culture. Mild positive from knowledge sharing and cultural participation.

+0.08
Article 28 Social & International Order
Medium P:ordered_liberty A:knowledge_order
Editorial
+0.10
Structural
+0.05
SETL
+0.07
Combined
ND
Context Modifier
ND

Article 28 requires social and international order to realize UDHR rights. Editorial: educational content supports knowledge order and intellectual infrastructure. Structural: orderly, well-organized content accessible globally; supports knowledge infrastructure. Minimal positive from contribution to informed society.

+0.10
Article 29 Duties to Community
Medium P:duty_community A:knowledge_sharing
Editorial
+0.10
Structural
+0.10
SETL
0.00
Combined
ND
Context Modifier
ND

Article 29 addresses duties to community. Editorial: sharing technical knowledge freely represents contribution to community good and human development. Structural: publicly accessible without extraction of payment/data premium; supports duty fulfillment rather than pure market extraction. Mild positive.

0.00
Article 30 No Destruction of Rights
Low P:no_destruction
Editorial
ND
Structural
0.00
SETL
ND
Combined
ND
Context Modifier
ND

Article 30 prohibits using UDHR to destroy rights. No evidence of such destruction in technical blog. Content does not advocate for UDHR limitation. Neutral.

About HRCB | By Right | HN Guidelines | HN FAQ | Source | UDHR
build fc56cf0+0q5s · 2026-02-25 01:32 UTC