&gt; We had a &quot;reporting&quot; database that was postgres 9.3 or 9.4 (can&#x27;t remember). It was the same schema but was never pruned.<p>Big no-no right there -- a reporting database shouldn&#x27;t have the same schema as your main transactional DB, because the latter is designed and built for write-heavy workloads, not reporting or analytical ones.<p>I&#x27;m pretty certain that a lot of the stuff happening in the CTEs could simply be designed as part of a &quot;true&quot; reporting schema and ETL&#x27;ed in as a batch job.