The problem
An outbound-sales reporting dashboard took about 15 seconds to load, repeating reporting calculations on every request.
The dashboard used Node.js, Prisma and GraphQL over PostgreSQL. The optimization needed to preserve existing software integrations and support reporting across active and historical campaigns.
What I did
I analyzed reporting queries across campaign, lead, manager and industry metrics. The investigation identified repeated aggregation work that could be moved out of the dashboard request path.
I introduced materialized views and precomputed campaign and lead metrics, then revised the dashboard queries to use those results. Active and historical campaigns received filtered aggregation paths.
Technical details
CampaignMetricCombined and ActiveClient materialized views supported the new reporting structure. Manager and industry aggregation moved into prepared data, allowing the API to retrieve results with less repeated computation.
Before · work on every request
- Dashboard API
- Joins and aggregation
- Raw reporting tables
- About 15s dashboard load
After · prepare once, read efficiently
- Dashboard API
- Revised queries
- Materialized / pre-aggregated data
- About 2s dashboard load
Pre-aggregation speeds up reads but requires data refreshes. Refresh frequency determines how current the dashboard can be.
The result
Reported dashboard load time improved from approximately 15 seconds to 2 seconds, an 87% reduction, after introducing materialized views, pre-aggregation and revised queries.