Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

112
Vistas
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)

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Do you have several options:

  • @ittus's and @Andrey Shipilov's approach: store result in cache system like Memcache or redis. You can check github.com/niwinz/django-redis

  • @Anonymous's approach: use some sort of materialized view (depends on your db), and then create a unmanaged model in django to query it.

  • Create new models/fields for aggregate data and figure up it nightly though a django custom comand or a celery task.

Conclusions:

  • Your question should be close because is a primarily opinion-based question, like this one Django - what is best practice - Calculating field values.

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.
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda