Pergunta

Eu quero criar um aplicativo do tipo 'Google Analytics' para a web - ou seja, uma ferramenta baseada na web para fazer alguns relatórios e gráficos para o meu banco de dados. O problema é que o banco de dados é enorme, por isso eu não posso fazer as consultas em tempo real, porque eles vão demorar muito e a ferramenta ficará sem resposta.

Como posso usar um trabalho cron para me ajudar? Qual é a melhor maneira de ser capaz de fazer os meus gráficos responsivo? Acho que vou precisar denomalize algumas das minhas tabelas de banco de dados, mas como faço para fazer essas consultas mais rápido? Que valores intermediários posso armazenar em outra tabela de banco de dados para torná-lo mais rápido?

Obrigado!

Foi útil?

Solução

Business Intelligence (BI) is a pretty mature discipline - and you'll find answers to your questions in any book on scaling databases for reporting & data warehousing.

A high-level list of tactics would include:

  • partitioning (because indexes are little help for most reporting)
  • summary tables (generated usually through a batch process submit via cron)
  • you need a good optimizer (some databases like mysql don't - so make poor joining decisions)
  • query parallelism (some databases will provide linear speedups just by splitting your query into multiple threads)
  • star-schema - a good data model is crucial to good performance

In general dynamic reporting beats the pants off static reporting - so if you're after powerful reporting I'd just try to copy data into an appropriate model, use aggregates, possibly change the database to get a good optimizer and the appropriate features rather than run reports in batch.

Outras dicas

A simple way to approach this would be to create a selection of summary tables to contain pre-aggregated data. These could be populated on a regular basis using crontab.

Alternatively, it may be worth looking at something like http://mondrian.pentaho.org.

I would get myself familiarized with "star schemas"

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top