typing machine

adesso blog

Performance might not be the first thing that comes to mind when building an application. Often, the application is 'fast enough'. Until it isn’t. Sometimes, performance becomes such a pressing issue that it impacts the business directly. In this blog post, I’ll share the most significant performance improvement I’ve ever achieved and the surprising results that followed.

The Problem

I once worked for a company that had a script which needed to finish execution before a certain time each day. The problem? It was getting slower every day. Eventually, the script took over five hours to complete. It became such a bottleneck that even the business stakeholders were aware of the existence of this script, a rare and worrying sign.

The underlying issue involved three database tables:

  • Table A: Each row was related to multiple rows in Table B
  • Table B: Each row was related to multiple rows in Table C
  • Table C: Contained additional data tied to Table B

All three tables had thousands, if not millions, of rows. Performance was clearly suffering, but no one really knew what happened. So, I volunteered to take a closer look.

What I Discovered

After diving in, I quickly learned that:

  • 1. There wasn’t just one script, there were three;
  • 2. All scripts were stored procedures in the database;
  • 3. Around 75–80% of the logic involved transaction handling;
  • 4. The scripts were written in an object-oriented way (in SQL!);
  • 5. Cursors were being used to iterate over the data.

Yes, that’s right! Every row in Table A was being iterated over, and for each row, the script looped through all rows in Table B to find related records. Then it did the same for Table B and Table C.

The only goal of these scripts? Updating a few status and date fields.

Then I began to wonder: Why aren’t we just using a single update query?

The Solution

To test my theory, I planned the following steps:

  • 1. Replace script 3 with an update query;
  • 2. Integrate this update query into script 2;
  • 3. Repeat for script 2 and script 1, combining all logic into a single, optimized update query.

What I ended up writing was the largest update query I’ve ever written in my career. The only question was: how would it perform?

To test the new query, I took a copy of the production database and ran it.

The Result

I wasn’t sure what to expect. I grabbed some tea and was mentally prepared for a long wait. But then something unexpected happened:

The query finished in just six minutes.

I was stunned, as was the rest of my team. After thorough testing confirmed the output was identical to the old script, I called the business owner to share the news. I don’t think I’ve ever heard someone sound that happy over a technical change.

This script, once infamous within the company, now took only minutes to execute.

The Lesson

To this day, this remains one of my biggest successes. It serves as a reminder that performance optimization is not just about shaving milliseconds. It can change workflows, save hours, and make customers genuinely happy.

You might not always achieve results this dramatic. But even small improvements, like reducing response time from 10 seconds to 2, can make a big difference to your users.

Don’t underestimate the power of optimization.

Contat us

Picture Stefan  van der Steen

Author Stefan van der Steen

As Java Software Engineer Stefan van der Steen is part of the growing CodesSquad of adesso Netherlands.