News for hackers. Stuff that matters.
Re:Squeeze the hell out of the system you have by endisneigh on Friday August 11, 2023 @03:40PM (#37093040)
Yes, but I assert that it's possible to use transactions to update everything consistently. If you agree with this, than its easy to prove that denormalized tables performance increase is well worth the annoyance of updating everything to transactionally update the dependencies.

I won't say that it's trivial to update all of your business logic to do this, but I think it's definitely worth it for a new project at least.

Re:Squeeze the hell out of the system you have by Guvante on Friday August 11, 2023 @03:48PM (#37093128)
You always need to compare write vs read performance.

Turning a single table update into a 10 table one could tip your lock contention to the point where you are write bound or worse start hitting retries.

Certainly it makes sense to move rarely updated fields to where they are used makes sense.

Similarly "build your table against your queries not your ideal data model" is always sage advice.

Re:Squeeze the hell out of the system you have by Bognar on Friday August 11, 2023 @03:51PM (#37093175)
Denormalized transactions are not trivial unless you are using serializable isolation level which will kill performance. If you don't use serializable isolation level, then you risk either running into deadlocks (which will kill performance) or inconsistency.

Decent SQL databases offer materialized views, which probably give you what you want without all the headache of maintaining denormalized tables yourself.

Re:Squeeze the hell out of the system you have by endisneigh on Friday August 11, 2023 @03:57PM (#37093246)
all fair points, but to be fair I don't necessary think this makes the most sense for an existing project for the reasons you state. I do think for a new project would best be able to design around the access patterns in a way that eliminate most of the downsides.
Re:Squeeze the hell out of the system you have by williamdclt on Friday August 11, 2023 @04:36PM (#37093693)
Transactions are not only (actually mainly not) about atomicity. Of course it’s possible to keep data integrity without normalisation, but that means you need to maintain the invariants yourself at application level and a big could result in data inconsistency. Normalisation isn’t there to make integrity possible, it’s there to make (some) non-integrity impossible.

Nobody says you have to have only one view of your data though. You can have a normalised view of your data to write, and another denormalised for fast reads (you usually have to, at scale). Something like event sourcing is another way (which is actually pushing invariants to application level, in a structured way)

Re:Squeeze the hell out of the system you have by sgarland on Friday August 11, 2023 @08:02PM (#37095507)
> that means you need to maintain the invariants yourself at application level

Foreign Keys.

Of course, now you have a new set of problems, but referential integrity isn't one of them.