Reporting screens are usually the first place a growing system starts to feel slow. On a fintech platform processing a high volume of daily transactions, our settlement and transaction reports were taking far too long, and merchants noticed. Here is the approach that cut our reporting query time by around 35%, without new hardware.
STATISTICS IO and Query StoreGuessing is expensive. Start with the actual execution plan and turn on statistics to see logical reads and CPU time per query. Logical reads are the number to watch: if a report reads millions of pages to return a few hundred rows, you have found your problem.
SET STATISTICS IO, TIME ON;
EXEC dbo.rpt_MerchantSettlements @MerchantId = 1042, @From = '2026-11-01', @To = '2026-11-30';
-- Messages tab: look at "logical reads" per table and total CPU time
On SQL Server 2016 and later, Query Store shows which queries consume the most resources over time, so you fix what matters first instead of what looks slow today.
Most slow reports come down to scans on large tables. A covering index with the right key order turns a full scan into a seek: put equality filters first, then range filters, and add the returned columns as INCLUDE columns.
CREATE NONCLUSTERED INDEX IX_Transactions_Merchant_CreatedAt
ON dbo.Transactions (MerchantId, CreatedAt)
INCLUDE (Amount, Status, OutletId);
Every index slows down writes, though. On transaction-heavy tables, add only what the workload justifies and remove indexes nobody uses. The sys.dm_db_index_usage_stats view tells you which ones those are.
Wrapping a column in a function prevents SQL Server from seeking on the index, so it scans everything instead. Rewrite filters as ranges on the raw column:
-- ❌ Scans: the function runs on every row
WHERE CAST(CreatedAt AS date) = @Day
-- ✅ Seeks: a plain range on the indexed column
WHERE CreatedAt >= @Day
AND CreatedAt < DATEADD(day, 1, @Day)
The same applies to implicit conversions caused by mismatched data types, for example comparing a VARCHAR column with an NVARCHAR parameter.
Cursors, loops and scalar functions in SELECT lists force row-by-row work. Replacing them with joins, aggregates and window functions is often the single biggest win. For example, a running balance per merchant needs no loop at all:
SELECT MerchantId,
CreatedAt,
Amount,
SUM(Amount) OVER (PARTITION BY MerchantId
ORDER BY CreatedAt
ROWS UNBOUNDED PRECEDING) AS RunningBalance
FROM dbo.Transactions
WHERE CreatedAt >= @From AND CreatedAt < @To;
If a dashboard always shows daily totals per merchant, calculate them once instead of aggregating millions of rows on every page load. A summary table refreshed by a scheduled job (or an indexed view) keeps the dashboard fast no matter how big the raw table grows.
INSERT INTO dbo.DailyMerchantTotals (MerchantId, TxnDate, TxnCount, TotalAmount)
SELECT MerchantId, CAST(CreatedAt AS date), COUNT(*), SUM(Amount)
FROM dbo.Transactions
WHERE CreatedAt >= @Yesterday AND CreatedAt < @Today
GROUP BY MerchantId, CAST(CreatedAt AS date);
Combine this with proper pagination (OFFSET … FETCH or keyset paging) so screens never pull more rows than they show.
SQL Server caches a plan based on the first parameters it sees. A plan compiled for a small merchant can be terrible for a large one. For heavy reports that run infrequently, recompiling on each run is a cheap way to keep performance predictable:
SELECT ...
FROM dbo.Transactions
WHERE MerchantId = @MerchantId
AND CreatedAt >= @From AND CreatedAt < @To
OPTION (RECOMPILE);
For frequent queries, OPTIMIZE FOR hints or Query Store plan forcing are better options, since recompiling costs CPU every time.
Performance work is a loop: measure, change one thing, measure again. Most of our gains came from indexing, SARGable filters and set-based rewrites, not exotic tricks.
WHERE clauses