title: How to create summary tables efficiently
body: <p>During a month a process inserts a large number of rows in some database tables ~1M.<br>
  This happens daily and the whole process lasts ~40mins. That is fine.<br>
  I created some "summary tables" from these inserts so as to query the data fast. This works fine.</p>
  
  <p><strong>Problem</strong>: I keep inserting data in the summary tables and so the time to create the cache table matches the process to insert the actual data and this is good. But if the data inserted in the previous days have changed (due to any updates) then I would need to "recalculate" the previous days and to solve this instead of creating today's summary data daily I would need to change my process to recreate the summary data from the beginning of each month which would mean my running time would increase substantially.<br>
  Is there a standard way to deal with this problem?</p>