Re:Denormalization for Performance: Don't Blame the Relation...
by idbehold on Tuesday October 18, 2016 @11:43PM
(#12740893)
Well you clearly have cache invalidation figured out. Any tips on naming things?
Re:Denormalization for Performance: Don't Blame the Relation...
by CurtMonash on Wednesday October 19, 2016 @12:17AM
(#12741030)
Similarly -- any thoughts about off-by-one?
Re:Denormalization for Performance: Don't Blame the Relation...
by endymi0n on Wednesday October 19, 2016 @07:06AM
(#12742728)
Concurrency
Nice one. The only hard thing missing now is:
Re:Denormalization for Performance: Don't Blame the Relation...
by andreareina on Wednesday October 19, 2016 @01:11AM
(#12741247)
The nice thing about SQL queries is that they tell you what the dependencies are. It's still hard, but not intractable.
Re:Denormalization for Performance: Don't Blame the Relation...
by sgeneris on Wednesday October 19, 2016 @12:50AM
(#12741161)
To a hammer ...
Re:Denormalization for Performance: Don't Blame the Relation...
by xiphias on Wednesday October 19, 2016 @01:38AM
(#12741346)
If you write often, another way is to use triggers. They can be extremely useful for this kind of scenerio.
Re:Denormalization for Performance: Don't Blame the Relation...
by sp527 on Wednesday October 19, 2016 @02:28AM
(#12741561)
Agreed. 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.
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.)