# Calculating ROI on Performance Tuning

Recently on the SSC forums, someone asked about how to measure the money in an actual dollar figure that they have saved the company with their performance tuning.  I've often struggled with this myself, and so I started thinking about it a bit deeper.  I started to respond in the thread; then decided I was going to be a bit too long winded so I moved it here.   The following are some of my thoughts/opinions on the subject.

I think everyone will agree that it's probably not worth the time to optimize a report that runs once a month at 3 AM on a Saturday to go from 10 minutes to 2 minutes.  Most people would also agree that it's worth optimizing a query that users have to wait on nonstop all day long to take it from 5 seconds to 2 seconds (or even 4.5 seconds depending on the amount of time it'd take to accomplish that change, 10% is still pretty huge for something being used constantly).  For the latter, you can probably take the improvement percentage and multiply it by the salaries of all those affected and come up with a number... but is it fair to assume that that number goes straight to you?

Let's take a data entry process for an example.  We'll say we have employees doing data entry and 50% of their time is spent entering things that rely on a stored procedure that takes 5 seconds to run.  You improve that SP to run in 1s.  While this is obviously an improvement, is it fair to take 80% of 50% of their pay and attribute it to your performance savings?  I'd say not.  For one thing, you have the keying in of the information before they hit save and wait on the query.  Let's say they spend half their time typing and half of it waiting on that query to run.  We're now talking about 80% of 25%.  Then, factor in the rest of the process.  Perhaps that 5 seconds that they spend 'waiting' is really spent flipping to the next page of their data or tabbing to some other application which it takes them 3 seconds to do anyways.  Now you're only talking about 40% of 25%.

At the very least, you can *guess* at what number you saved there.  The numbers are a lot harder to get for anything that users don't directly wait on.  A few examples of these types of queries might be:

Agent Jobs that run constantly throughout the day
Pre-aggregated reports or data tables that run periodically and store that data for on demand usage
Processes that take only milliseconds but might perform more reads or writes than necessary but are run hundreds of thousands of times a day.

Is there any direct ROI on improving these things?  Maybe... maybe not.  If that process that takes a few milliseconds but runs constantly takes more locks than it truly needs, it could lead to slowing everything else down by fractional amounts or cause blocking/deadlocking issues in your database that 'freeze' users and force them to wait, thus wasting time and money.  However, maybe it never would have gotten to that point.  If you weren't proactive with fixing that because it wasn't causing any problems right now, it could end up costing the company tens or hundreds of thousands of dollars in lost productivity if and when it DID become a problem.  You could measure that.  But is it fair to measure it if you addressed the issue preemptively and it never happened?  How do you come up with a number in this case?  How do you decide what to count *for* yourself and what to count against yourself?

Going a completely different route, let's look at bug fixing.  Let's say you identify a loophole in the invoicing process that only applies to .05% of invoices because of the rare criteria.  Maybe that loophole only cost you a few hundred dollars for the 2 years it has existed, but it *could* have cost you thousands depending on which line items it happened to affect.  Do you count the hundreds of dollars it already cost you, or the thousands of dollars it would have eventually cost?

At the end of the day, if you really want to calculate a dollar value of the things you've done, I think you have to break things down to a very low level.  Create a range for each thing you fix, improve or create and have that range readily available.  Then when someone asks, you can present your numbers with a range for each item and they can make up their own mind at what is fair.

Unfortunately, most companies view IT/Development as a 'necessary evil' that doesn't produce anything.  These numbers probably aren't going to change their minds, but you should at least be able to keep the focus on 'necessary' and off of 'evil'.  The irony is that just about everything work related you do potentially saves or makes the company money in some manner... everything except sitting around trying to calculate how much money you've saved them.