Measure before changing the query
A slow dashboard can have several causes: repeated database calls, large result sets, expensive calculations, or a slow external service. Capture the request duration and inspect the queries before deciding on a fix. A page with many small queries may need a different solution from a page with one expensive aggregation.
Watch for repeated relationship loading
A customer list that loads invoices separately for every customer can generate unnecessary database traffic. Load the required relationships or aggregate values together. Select only the fields needed for the response, and paginate large lists instead of sending every record to the browser.
Design indexes around real filters
Business reports often filter by company, date range, status, or branch. Review the query execution plan and consider indexes that match frequent access patterns. Indexes also consume storage and add work to writes, so adding an index to every column is rarely a useful strategy.
- Use realistic data volumes when measuring performance.
- Check that company and permission filters remain in every query.
- Compare results before and after the change, not just response times.
- Keep date boundaries and time zones consistent across reports.
Cache with an explicit freshness rule
A daily management summary may tolerate older data, while an available-stock check may need current values. Define how fresh the information must be before adding caching. Include the company and relevant filters in cache keys so results cannot leak between customers.
Performance work succeeds when a dashboard becomes faster while preserving the numbers that users rely on.