Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda