4 ms·
From my experience, denormalization of a relational model is a special case of "caching". What you are really doing is caching data where it is most likely to b
by EGreg 10y ago
From my experience, denormalization of a relational model is a special case of "caching". What you are really doing is caching data where it is most likely to be used at access time.
The overview is like this:
1) You need some operation to have low turnaround time / latency
2) So you maintain and update a cache, typically while writing to the data store.
3) Like all caches, you can either invalidate it before changing the data, slightly harming availability, or you can have it lag behind (eventual consistency).
So the article is actually wrong, you don't need to trade consistency for performance. You can increase read performance (lower latency) without losing consistency, by having a cache (denormalization) and invalidating the relevant caches BEFORE writing data (which lowers write latency, but not necessarily write throughput... typically, we don't care about write latency as much as read latency.)
- idbehold 10y agoWell you clearly have cache invalidation figured out. Any tips on naming things?
- CurtMonash 10y agoSimilarly -- any thoughts about off-by-one?
- endymi0n 10y agoConcurrency Nice one. The only hard thing missing now is:
- andreareina 10y agoThe nice thing about SQL queries is that they tell you what the dependencies are. It's still hard, but not intractable.
- sgeneris 10y agoTo a hammer ...
- xiphias 10y agoIf you write often, another way is to use triggers. They can be extremely useful for this kind of scenerio.
- sp527 10y agoAgreed. Triggers are especially useful for maintaining counts. If you want to feel extra smug, there's a post from Instagram eng about how they realized they should denormalize counts of likes only pretty late in the game.
- sgeneris 10y agoThe basic issue is that derived data should not be included in base relations -- they belong in derived relations, such as views.