Data platforms

Payroll reporting, 155 times faster

We rebuilt the SQL behind an automated weekly payroll report for a multi-company group. It now runs about 155 times faster, with exactly the same numbers.

The challenge

A group of companies relied on an automated weekly payroll report, produced from their database and distributed by email to the people who needed it. The report was accurate, but the query behind it had grown slow as data built up across the companies in the group. Slow reports cost compute, delay the people waiting on them, and put the weekly schedule at risk.

What we did

We worked out where the query was spending its time, then rebuilt the underlying SQL. The main change was restructuring the work into temporary tables, so the database could process each stage once instead of repeating the same expensive steps.

Long queries often grow this way: a join added here, a subquery there, until the database is recalculating the same intermediate results many times over. Breaking the work into clear stages, each stored once and reused, gives the database a much simpler job and makes the logic easier for the next developer to follow.

Speed only matters if the numbers stay the same, so we checked that the new version produced exactly the same output as the old one before switching over.

The report is part of a wider automation and reporting platform we built and support for the group on Azure.

The result

The weekly payroll report now runs about 155 times faster, with exactly the same numbers as before, and goes out on schedule without anyone waiting on it.

It’s a good example of where performance work pays off: no new system, no change for the people reading the report, just the same result arriving far sooner. If you have reports that time out or take minutes to load, the fix is often in the query rather than the hardware. See our data platforms work for more.

Got a problem like this one?

Tell us about the report nobody trusts or the process that eats a day a week. We'll tell you straight whether we can help, and what it would take.