alphagov/transition — pull request #457 by rgarner (2014-11-13 11:25:12+00:00)
Title: Increase `work_mem` available to `daily_hit_totals` refresh

Before (preview): 5m32.45s
After (preview): 40.61s

The query plan was thrashing to disk - starting at around 128MB `work_mem` it starts using a `HashAggregate`, not a `GroupAggregate`. This has a nice effect on the overall time taken to execute and can buy us a few minutes every hour on the `import:hits`-running job.

(for reference, we tried gussying up a `MATERIALIZED VIEW` and the creation of that took around 17s, the refresh 12s, so that'd be faster again and would involve deletion of some code should we choose to do it)