Why database baselining and benchmarking matter
When an application slows down, the first instinct is often to add more hardware: more memory, faster storage, or a bigger server. But the problem may sit somewhere else: in the application, the database design, or the SQL statements running against it. Without performance data, it is easy to make a change without knowing whether it addresses the real bottleneck.
Baselining helps you establish what is normal, while benchmarking shows how the system behaves under a defined workload. With representative workloads and repeatable tests, you can identify bottlenecks and use what you learn to support performance monitoring and alerting.
The difference between a baseline and a benchmark
A baseline tells you what is normal. It tracks performance over time so you can understand the behavior you expect from a particular workload. That might include CPU activity, wait statistics, response times, and other metrics you monitor day to day.
A baseline describes what you observe, not necessarily what good performance looks like. If a problem has persisted, the baseline may reflect it. A benchmark, by contrast, measures performance under specific workload conditions.
For example, your application might normally support 500 concurrent users. You could run a benchmark to see what happens with 2,000. The goal is to find bottlenecks and shortcomings before your users do. You can then make a performance tuning change, run the test again, and compare the results.
Benchmarks are also useful when you want to compare an existing database version with an upgrade, an important update, or a migration from one environment to another, such as a cloud migration. Running the same workload against both can help reveal performance regressions or new errors before a change reaches production. This gives you a consistent basis for comparing the results.
Start with a business goal
Before you build a test, be clear about what you need it to tell you. “I want to see what this server can do” is a starting point. But a specific business requirement gives you something more useful to measure against.
Suppose a reporting application needs to deliver any report a user requests in less than 20 seconds. From there, you can define the technical conditions your test needs to cover, such as a target transaction rate and number of concurrent users. Write down your assumptions too.
If you expect the system to remain in use for several years, consider capacity planning and how the workload might grow over that period. A test based only on today’s users may not answer the questions you will face later. The clearer the goal, the less likely you are to spend time answering questions nobody asked.
Build a workload that reflects the real world
A useful benchmark needs more than a large number of transactions. It needs the right mix of transactions. Think about the people and processes using the application. You may have users running reports, others looking up individual records, and others inserting or updating data. Your test should reflect that mix as closely as practical. Consider:
- The SQL statements and stored procedures the application uses
- The balance of reads, inserts, updates, and deletes
- The number and types of concurrent users
- The size of the database and its schema
- The reporting and analytical workloads that run alongside transactional activity
A synthetic workload can help you explore how a system behaves. But it is not the same as your application’s actual workload, so keep that distinction in mind when you interpret the results. Choose the workload based on the question you need to answer.
Make each test repeatable
One of the biggest surprises in my early benchmarking work was how much time it took to get back to the starting point between tests. You might initially think that all you have to do is restore a database under test back to its earlier pre-test conditions, but that’s only a small part of resetting the benchmark for another run. You run a test, make a small change, and run it again. For the comparison to mean anything, you need to control the conditions around that change.
Document the system under test (SUT), including the database schema and configuration, server settings, and relevant virtual machine or cloud details. Differences in the environment can affect the results, even when you think you are comparing like for like. Then prepare a restart sequence. Depending on your test, that might mean:
- Collecting logs, errors, and performance data from the previous run
- Resetting alert counters
- Restoring the database to its starting state
- Keeping cache conditions consistent between runs, whether cold or warm
- Preparing your monitoring for the next run
A restore that takes an hour can limit how many tests you can complete. Plan for that before you begin, not after your first run. Include the time needed to reset the environment in your test plan.
Choose the right tool for the workload
HammerDB is one option for running database workloads against a system under test. It can build a schema, populate it with data, and run transactional or analytical workloads. You can also increase the number of virtual users to see how the system behaves as the workload grows.
I recommend running the load generator on a separate server from the one you are testing. Otherwise, the tool generating the workload can consume resources on the system under test and affect your results. If you are working with SQL Server and want to test an existing workload, Spaghetti DBA’s WorkloadTools can capture, replay, and analyze it. Whichever approach you choose, remember what you are testing. A standard workload can be useful, but it does not automatically reproduce the behavior of your own application.
Collect the data, then look for patterns
While the test runs, monitor the database and, where possible, the application and any middle tier. That gives you a broader view of what is happening across the system. Collect your errors and event logs alongside DMVs, performance counters, and wait statistics. I like to store the data in SQL tables and analyze it there, but PerfMon or a spreadsheet can work too.
Look at the minimum, maximum, average, and standard deviation for the metrics you collect. These help you understand not just a single result, but the range and variation in your workload. Remember that normal changes with the business cycle. A workload may look different at the end of the week, at month end, or during quarter close. Backups and other maintenance can also affect what you see.
When you find something useful, share it with the other teams involved. Infrastructure and storage teams may need the same evidence to understand what happened and decide what to change. The results can give those teams a common starting point for the discussion.
Use baselines to improve monitoring and alerting
Once you understand normal behavior, you can use it to make your alerts more meaningful. A fixed CPU threshold can tell you when utilization is high. But unusually low activity can matter too. If a database that is normally busy suddenly goes quiet, that may be worth investigating.
A baseline gives you a way to look for changes in either direction. Standard deviation can help you assess how far a value is from its typical range, but the right alerting threshold depends on the workload and the response you need. You may also need different baselines for different periods. A month-end reporting workload should not necessarily be judged against an ordinary Tuesday morning. I covered this approach to alerting in more detail in How To Create Database Alerts You Can Trust.
How SolarWinds tools support baselining
You can collect and analyze performance data yourself, but it takes preparation and ongoing work. In the webinar, I showed how two SolarWinds tools help with baselines and performance analysis. SolarWinds® Database Performance Analyzer (DPA) software collects performance data and uses anomaly detection to help identify behavior that differs from expected patterns. In the demonstration, I showed how its views and advisers can help you investigate performance issues.
SolarWinds® SQL Sentry® software offers time-based baselines that let you compare a period with the previous period, day, or week. You can also create a custom baseline from a selected period on the performance dashboard. That is useful when you want to compare a workload against a relevant period, such as management reporting or month-end processing, rather than a routine part of the day.
These tools help you analyze performance. You still need to define the test and construct a workload that answers your question. Your results depend on the conditions you choose to test.
What high-performance DBAs do differently
Baselining and benchmarking are not one-off exercises. They are part of building a more consistent, predictable way to manage database performance. The process starts with a clear goal. It continues with a representative workload, a documented environment, repeatable tests, and an honest assessment of the results.
Those results can then inform your monitoring and alerting, help you evaluate changes, and give your team evidence to work from when performance shifts. They also give you a way to compare results when you test a change. You cannot know what is abnormal until you understand what normal looks like.
Frequently asked questions
What is the difference between a database baseline and a benchmark?
A baseline describes normal performance over time. A benchmark measures how a system performs under specific workload conditions, such as a particular number of concurrent users. Both help you understand performance from different perspectives.
When should I benchmark a database?
You can benchmark when you want to understand how a system handles a workload, to prepare for a migration or upgrade, or to investigate future bottlenecks. You can also compare performance before and after an upgrade or other change. Running the same workload under consistent conditions makes the results easier to compare.
Does a benchmark need to use my application’s actual workload?
Not always. A standard workload can help you test a system, but it may not reflect your application’s transaction mix or behavior. Choose the workload based on the question you need to answer.
Why do test conditions need to stay consistent?
If the database, cache, server settings, or other conditions change between runs, it becomes harder to tell which change caused a difference in the results. Keeping those conditions consistent makes it easier to compare the effect of the change you are testing. Document the environment and prepare a restart sequence before you begin.
How can a baseline improve database alerts?
A baseline helps you understand the expected range for a workload. You can use that context to investigate unusual lows as well as highs and account for patterns such as month-end reporting. The right thresholds depend on your workload and the response you need.
Resources
- How To Create Database Alerts You Can Trust
- More Databases, Same Headcount?
- Performance Baselining and Benchmarking for Databases webinar
Watch the full webinar
The webinar goes into more detail on preparing your tests, analyzing performance data, and using SolarWinds tools to work with baselines. It includes demonstrations of the approaches covered in this post. Watch the webinar on demand.