Query / SP tuningWholesale parts distributor, anonymized × red9CS-0004
A parts distributor's receiving procedure went from a bottleneck to 40x faster
The problem. The distributor kept getting held up at the receiving desk. One stored procedure on its ERP handled every inbound shipment, and it had grown heavy enough to drag, roughly 687,157 logical reads on each call, worst exactly when trucks stacked up and stock came in fastest.
What we did. We captured the procedure's plan and its IO statistics, rewrote it, and built a covering index around the columns it filters and returns, so the engine seeks a handful of rows in place of reading the whole receiving table. We took the before and after numbers in one sitting.
Red9 · Performance Impact
Procedure speed
40x faster
The same receiving procedure, on the same hardware.
Disk reads, per call
687,157 → 90
Storage load lifted off the instance.
Access pattern
scan → seek
A covering index replaced the full scan behind the receiving procedure.
Speed
runtime → 1/40th
40x faster
Disk reads
687,157 → 90
scan gone
40x faster
after the rewrite
How the math works. The 40x is the procedure's runtime before the rewrite against its runtime after. The read drop, 687,157 pages down to 90, is what a full scan turning into an index seek looks like. Both figures come from the distributor's own before-and-after captures.
The result. The receiving procedure runs about 40 times faster and touches 90 pages where it used to read 687,157. The storage it was burning is back for the rest of the ERP, so the desk keeps moving when a shipment rush hits.
The technical detail
What the review found. The receiving procedure filtered a large table that had no index fit for its pattern, so every call scanned the table from end to end, about 687,157 reads apiece.
What we changed (identifiers generalized for privacy):
-- Receiving procedure scanned the full table: 687,157 logical reads per call.
CREATE NONCLUSTERED INDEX IX_inbound_receipts_covering
ON dbo.[inbound_receipts] (/* filter cols */) INCLUDE (/* output cols */);
-- procedure rewritten to seek the covering index; DROP INDEX rollback provided
The rewrite and the covering index turned the scan into a seek: reads fell from 687,157 to 90, and the procedure came back about 40 times faster.