In terms of databases, is “Normalize for correctness, denormalize for performance” a right mantra?

The two most common reasons to denormalize are: Performance Ignorance The former should be verified with profiling, while the latter should be corrected with a rolled-up newspaper 😉 I would say a better mantra would be “normalize for correctness, denormalize for speed – and only when necessary”

Django: How to access original (unmodified) instance in post_save signal

I believe post_save is too late to retrieve the unmodified version. As the name implies the data has already been written to the db at that point. You should use pre_save instead. In that case you can retrieve the model from the db via pk: old = Vote.objects.get(pk=instance.pk) and check for differences in the current … Read more

In what way does denormalization improve database performance?

Denormalization is generally used to either: Avoid a certain number of queries Remove some joins The basic idea of denormalization is that you’ll add redundant data, or group some, to be able to get those data more easily — at a smaller cost; which is better for performances. A quick examples? Consider a “Posts” and … Read more

How does data denormalization work with the Microservice Pattern?

This is subjective but the following solution worked for me, my team, and our DB team. At the application layer, Microservices are decomposed to semantic function. e.g. a Contact service might CRUD contacts (metadata about contacts: names, phone numbers, contact info, etc.) e.g. a User service might CRUD users with login credentials, authorization roles, etc. … Read more

When and why are database joins expensive?

Denormalising to improve performance? It sounds convincing, but it doesn’t hold water. Chris Date, who in company with Dr Ted Codd was the original proponent of the relational data model, ran out of patience with misinformed arguments against normalisation and systematically demolished them using scientific method: he got large databases and tested these assertions. I … Read more