Anupam
Anupam

Reputation: 15620

Django store aggregated data in the database?

I have a use case where I have some complex functions (involving aggregations) that take a few seconds to run, and are affecting the UX of the app (even when the rows are just about 25-30k and the relevant fields are indexed). I am thinking of storing the aggregations in the database itself (and run them nightly) since real-time-liness of the data is not very important here. Is that a common practice with Django?

(I couldnt find much discussion on that on SO though)

Upvotes: 2

Views: 815

Answers (1)

dani herrera
dani herrera

Reputation: 51715

Do you have several options:

Conclusions:

Notice:

  • If you need real time calculation then you can overwrite save method on models to keep data or just connect a post_save signal.

Upvotes: 1

Related Questions