Contribute Media
A thank you to everyone who makes this possible: Read More

Denormalize All The Things!

Summary

Denormalize All the Things!

Thursday 2 p.m.--2:45 p.m.

Audience level: Intermediate

Description

What do you do when you need to cache a model but also need to query the cached data? You denormalize all the things! In this talk we will see how to create and maintain denormalized versions of some of your Django models in order to enjoy the benefits of caching while maintaining the benefits of relational data. Abstract Denormalized models: another copy of your data that you can query

Typical usage (with examples): pre-computed data a different view of your data combining multiple model

Keeping things synced The canonical data is always right

You must define the authoritative source of data and maintain it. Know thy parent

Keeping track of the canonical source (across database shards) Propagating changes manually (call a method on save) "use the signals Luke" (example)

Handling concurrency issues

The approach: you can't improve what you can't measure. Measure, fix, measure again, repeat.

Problems and some solutions (applying computer science goodness) one at a time: locks and mutexes (pylock) ensuring update order is correct

Details

Improve this page