districtr / districtr-v2

A free, open-source web app for drawing districting plans. Reboot of districtr.
MIT License
1 stars 1 forks source link

Create materialized views for gerrydb summary stats #193

Open raphaellaude opened 1 week ago

raphaellaude commented 1 week ago

Gerrydb tables and the UDFs to calculate their summary stats change infrequently. As such, we should explore using views–esp. materialized views–to avoid doing a lot of rework for every client by storing these summaries in a table.

Proposed schema would either:

If we go this route then we may want to explore lazy insert summary results, i.e. the summary endpoint first looks in the summary totals table for the totals and if it doesn't finds them, calculates them itself using the UDF then inserts the results for the next person.

Anyway this is definitely a perf thing so let's see if it's necessary to add this complexity or if it's fine w/o.