Missed the live session? Watch the full recording now.
How to Measure Your SQL Server

Brent Ozar
SQL Server Performance Expert ยท Founder, Brent Ozar Unlimitedยฎ
Read more
Key moments
0:04 Why these three numbers matter
7:42 Size: data volume and database count
16:46 Speed: batch requests per second
28:58 Workload: wait time
51:42 Capturing the three numbers with sp_BlitzFirst
Brent Ozar breaks down the three metrics every performance tuner needs to track: speed, workload, and size. He shows you exactly where to find them, what โnormalโ looks like, and what to do next when somethingโs off.
Agenda includes:
- The 3 core metrics every SQL Server admin should track
- Where to find these numbers in SQL Server
- What normal, healthy ranges look like
- How to spot common bottlenecks
- Next steps for troubleshooting once youโve found a problem
- Live Q&A from the session
Watch the full session
Sign up once and every full recording in the video hub opens for you.
By signing up, you agree to let JAMS Software store and process your personal data. See our privacy policy.
Read the full transcript
โพ
Read the full transcript
โพ
This transcript was generated from the recording and lightly edited for readability.
0:00 Why these three numbers matter
I have to know these. Oh. Oh, the recordingโs now in progress, so I better do the start again. So, hi everybody. Weโre going to be talking about three numbers that you need to know about your SQL Server and how you go about measuring those. I have to know these all the time because Iโm a SQL Server consultant. I specialize in emergency turnarounds and I need to know what things look like before and then what things look like after. I want you to know these because itโs really important when you talk to people like me at conferences or when you send me emails or when you post messages out on a forum or when you ask AI, when you put stuff into chat, GPT, Claw, Gemini, whatever, you want to give it these three numbers because the three numbers you give it are going to make a dramatic difference in the kinds of advice that you get. I give different advice for small servers as opposed to big servers or slow servers as opposed to to fast servers and youโll figure out where you rank relative to everybody else inside here. When youโre a performance tuner and doesnโt really matter what kind of performance weโre talking about, but when youโre a performance tuner, your job is to pick specific numbers. I donโt want to just work on what users report. I donโt want to believe it when a user says things are better or things are worse.
1:18 The car analogy: measuring speed and power
Users are not really paying attention to the screen. Theyโre like drinking coffee and they donโt notice exactly how long things take. So, I want to pick specific metrics and I want to measure those metrics before and then after my changes and make sure things are actually getting better. So, we think about numbers. Letโs think about it in terms of something that you probably use every day. A car. If I gave you the keys to a car parked right outside here and I said, โGo hop in that car and tell me whether the car is fast or not.โ Well, what you would do is you would open up the car, you would put your key in the ignition or push the start button, you would hammer the gas pedal, and you would see how quickly it takes before youโre going like an illegal rate of speed. And in order to do that, cars have nice handy gauges right in the front of them. They say thereโs a speedometer right there that tells you how fast youโre going in terms of miles per hour or kilometers per hour. Thereโs a tachometer that tells you how hard the engine is working in order to achieve those speeds. So, when weโre a car person, we like to measure cars in terms of their 0 to 60 time, how fast they can get to 60 mph. To tell you whatโs normal for that, letโs take the bestselling vehicle in the United States.
Now, this comes as a surprise to people who do not live in the United States. A lot of you in here are from other countries. You will be genuinely surprised that this is actually the top selling vehicle in the United States. We like them big. The Ford F-150, if you get behind the wheel of the base model and you hammer the gas pedal, itโs going to take you about 6 seconds in order to get to 60 m an hour. It takes six seconds because that thing is kind of a porker. It weighs a lot in terms of pounds, but itโs also kind of cheap. Thatโs why it sells really well here. Now, Europeans, they have a different attitude. Europeans have a different kind of popular selling car. In this case, Iโll take an Audi A3 as an example. These are much smaller hatchbacks, more optimized for city streets. And you know whatโs funny is both of these take about 6 seconds in order to get to 60 mph. But they get there by having different approaches. The the big Ford truck has to throw a lot of horsepower in it. Itโs got a much larger engine than the Audi because the Ford truck is a porker. Itโs pretty heavy. Itโs kind of funny that they both also cost about the same, too. But the Audi does, I guess, better engineering and smaller hardware.
And because itโs lighter, itโs able to get to 60 in the same time, even though it has a whole lot less horsepower. Now, if youโre a performance tuner, regardless of whether youโre from America or from Europe, and youโre sitting there with the keys to that car and you go, I want to go faster. The way that you measure faster is usually a faster 0 to 60 m an hour. So, as youโre standing at the dealer, you tell them, I want to trade this in for something that goes faster. Or Ford will sell you something with a much larger engine or Audi will send sell you something with a much larger engine in about the same size. So if we take the Ford F-150, if we put a big old engine in it, more than twice the power, it can get to 60 mph in about twice as fast. And same thing with the Audi, although itโs kind of interesting that the Audi gets to 60 in 3.6 six seconds with about the same horsepower as the base Ford F-150 just because itโs pretty light to begin with. But then you run out of options. If youโre standing at the dealer, the dealerโs going to go, โThatโs all I got.โ If you want to get to 60 faster than 3.6 mph, youโre going to have to make different changes as to the kinds of cars that you drive. Youโre not going to be able to drive a Ford F-150 or an Audi A3. Youโre going to have to make different architectural decisions.
Youโre going to have to buy something that is fundamentally different than the the car that youโre using today. And when you do that, you may have to make some compromises in terms of the way that the thing is designed, how you interact with it, the way that you manage it. But by build buying something thatโs on a totally different platform like say the Tesla Model S Plaid, youโre going to get to 60 mph in two seconds. Anybody whoโs ever sat inside an electric car, especially a high performance electric car, it reframes what you believe fast is. Just like a lot of us have never worked with a truly fast SQL Server and weโre like, โYeah, our SQL Server is pretty fast.โ But then you get behind the wheel of a really fast SQL Server and youโre like, โOh my god, this thing is jaw-dropping as youโre pinned back against the seat.โ Or you might do a really radical approach if youโre from Europe. This is an aerial atom. Just like the Audi took the approach of stripping things away from the car, making it more lightweight and smaller in order to go fast. This is the extreme example of that. That Tesla was a big giant porker. It has airbags. It has a nice stereo, climate control, you know, air conditioning, satnav, all these things.
The Aerial Atom has none of that. There are no doors here. You climb in. I donโt know if you can even see this little thing right here. That is the windshield. It is only designed to do a minute job of deflecting air away from your helmet. And I say helmet because if a bug hits your face while youโre driving one of these, that bug is going to become part of your DNA. Thereโs no air conditioning here. Thereโs just air. But as a result of that, as a result of making these extreme choices about architecture, you can get to 60 m an hour about the same time that it takes you to do it in a Tesla while using way less horsepower. Or in the world of servers, you could go really fast. Your customers could have a great experience if you strip things off the server. Hey, we like to run reports on the server. We track session state in there. We also use it as an XML store. Hey, Microsoft said you could put JSON in the SQL Server. Weโre going to put JSON in there, too. That is the equivalent of buying a Tesla, a big heavy car. You can get them to go fast, but itโs going to be expensive. And itโs not the only way to do it. The other way that you could do it is you could strip all that stuff off.
7:42 Size: data volume and database count
As I like to tell developers, when you want to store files somewhere, thereโs a thing for that. Itโs called a file server. Thatโs where we come up with the name for that. You donโt put JSON files in a database. Itโs a the database. Itโs for your data, not a file server. File servers are for files. Tuning is all about knowing your metrics. What are the metrics in the sense of a car? How big of a porker is this thing? How fast can it get to 60 m an hour? And whatโs the biggest bottleneck stopping us from going faster? Do we need a better engine? Do we need better aerodynamics? Do we need to do lightning? And so forth. Well, now letโs turn around and think about the same thing for our SQL servers. If I have you, if I give you the keys to a SQL Server thatโs sitting right outside the door and I have you go like kick the tires on that SQL Server and I have you go tell me how fast it is. Most of us have no idea even though we work with these things for a living all the time. All the time. All the time. When Iโm working with clients, they say things like, โWeโve put a lot of horsepower in this. We put a lot of heavy metal in this in order to get going.โ And Iโm like, โYou just no.
You have a Ford F-150.โ And the example I use all the time, Iโm stepping away from the camera so that I can go grab it. Example I use all the time is my laptop. I have a laptop just like all of you do. So when you think about is your SQL Server fast enough or fast or not, look at your laptop and compare the number of CPU cores that you have, the amount of memory that you have, the amount of solid state that you have on here. And thatโll start to reset your perspectives about whether or not your SQL Server is really fast. So we want three metrics about our SQL Server. We need to know how much weight our SQL Server is carrying around, how fast the SQL Server is going, and how hard is it working in order to achieve that speed or whatโs the biggest bottleneck thatโs stopping us from going faster. So metric number one, how much weight is our SQL Server carrying around? How much of a porker is it? The easy number to measure with this is just the total amount of data on the server. Go into Windows Explorer, rightclick on the file folder where the database lives and take up the total sum of database files.
Or if you want to go through DMVs, you can get it from CIS database files where type equals zero. Thatโs your data files because Iโm not really as concerned about log files for this. And if you want to track it over time, and Iโm a huge fan of tracking it over time, m the system table MSDB DBO backup file is wonderful because itโs constantly tracking every backup that you do, what the compressed size is, what the uncompressed size is, and I know most of you and you donโt clear that table out like youโre supposed to. Thatโs okay. Thatโs a topic for another webcast. But because youโre lazy, because you keep like 90 days worth of backups in there, even though you and I both know you are not restoring databases backups from 30 days ago, let alone 90. Because you probably have 90 days worth of history in there, you can build a quick trending report to see whatโs our database sizes going like over time. In software as a service environments where you not everybody does this but in environments where you put each client in its own database. I also like tracking the number of databases.
You might think how does the number of databases impact how SQL Server works. It impacts all kinds of things like the plan cache. It even impacts database startup time. When you get to the point where you have really large servers and weโll talk about what those numbers are. When you get to the point where you have really large servers, you start to learn that SQL Server actually starts up databases in database ID order. So you can have a situation where the SQL Server is up because you just restarted it, but because you have thousands of databases on the server, those last databases arenโt online yet and will take some time. Begins to have interesting impacts on things like our nines calculations. When this number goes up, when the total amount of data size on the server goes up, hopefully itโs because we have more sales, weโre shipping more products, we have more employees, whatever it is that weโre tracking inside that database. If itโs going down, hopefully itโs because people are dropping indexes we donโt need anymore, dropping log tables. We all know about that table sales before the deployment_204 that your predecessor put in there and you keep forgetting to go delete.
These things impact your backup times, your DBCC check DB times, your index rebuild times, anything maintenance-wise that you would do overnight. In a perfect world, I would track active versus inactive data, but SQL Server doesnโt really have the concept of that. Plus, when someone queries an archive table, you know how theyโre like, โOh, we have this archive data in here. It doesnโt matter. Nobody ever queries it. We just need to keep it around.โ And Iโm like, โGreat. We can delete it.โ No, we canโt because sometimes we do query it when you query it because you donโt have good indexes on it. SQL Server is going to scan the whole thing and drag the whole thing up into memory and your performance scoring to suck. David says, โLost audio.โ I still have audio coming through. So, weโre going to play a joke on David. And as long as you remember that, youโre completely fine. But if you miss that one point, youโre completely screwed. So whatโs normal out there in terms of database size from one to 150 gigabytes, itโs pretty easy to handle on standard edition. I donโt want to say itโs impossible to be slow, but if you get someone involved from a database administrative perspective, itโs relatively easy to get performance tuning done when the database is less than 150 gigs in size.
14:11 What normal data size looks like
From 150 to 500 gigs, itโs still really easy to handle with Enterprise Edition. Now, I donโt mean to tell you that you need Enterprise Edition if you have 150 gigabytes of data. You do not. I have one client with over 10 terabytes worth of data on standard edition and they are completely happy but itโs because they have tuned the living daylights out of their queries. There are no reports on this server. There are only point queries that dive directly into specific rows. Now I say 150 150 to 500 gigs itโs easy to handle with enterprise edition because you just throw hardware at it. You can throw memory at it. Even if you suck as a database administrator, you can still throw enough hardware at it and not do any tuning and youโll be okay. However, as you get over half a terabyte worth of data, it doesnโt matter whether you throw hardware at it or not, itโs easy to have slow performance because as queries start to scan a big old sales table, as queries start to scan a big old history table, that tableโs probably going to be too large to fit into memory. And weโre going to have to do some index tuning and query tuning in order to reduce that work.
Uncomfortable high-end about a 100 terabytes of data per SQL Server. That is not a limit. Iโm just saying those are the largest servers that Iโve worked with and 10 to 12,000 databases per server. Now you start to get an idea of how large your servers are relative to other people. And this is really useful because when you go to chat GPT me your peers at conferences I give very different answers for a 50 gigabyte database than I do a 50 terabyte database. They just require different methods of performance tuning. So thatโs the first number you have to know by heart when you are talking to someone else asking to get advice. Now I do have to say here that virtualization in the cloud change things in the sense that you are cooperating with other people on the same hardware. And in terms of cars, you can think of that as imagine if you were getting ready to run a performance test on a car. You were getting ready to run it from 0 to 60 m an hour to see how fast it would go. Imagine that you said, โAll right, everybody, before we go do this test, why donโt you all get your suitcases and letโs all go out to the garage.
16:46 Speed: batch requests per second
Letโs load in the biggest people that we have in the company and all of their baggage.โ And you know that your co-workers have baggage. Load all of them into the car and then letโs go see how fast itโll get to 60 mi. Of course, itโs going to be slower. Of course, virtualization in the cloud, if you put the exact same hardware on there, they are going to be slower because you are sharing those cycles with other people. Youโre sharing the network with other people. Youโre sharing the memory with other people. Youโre sharing the storage bandwidth with other people. I love virtualization. I love the cloud. You just want to be aware that as you start to cut costs, as you start to cut corners, when I say that, for example, itโs easy from 1 to 150 gigabytes to handle on commodity hardware with standard edition, that can change up in the cloud, especially when you start to size down your hardware to smaller than a laptop. We put this on a four core machine with 16 gigs of RAM. Great. I wouldnโt run my laptop on there. So that gives us our first number total data size in gigabytes or terabytes and the total number of databases on the server. Now for question number two, how fast are we going? I hate telling you in the year 2026 it is embarrassing as data data professionals thatโs what we are data profession.
It is embarrassing that we donโt have data on how long queries take. Donโt tell your peers this. Donโt tell your developers this. Donโt tell your managers this. Donโt tell your architects this. Because every tech professional in the universe asks things like, โHow long are things taking on average? Whatโs your P95 latency? How long are queries taking for the 95th percentile of queries? We donโt have that. We donโt even have queries per second. Itโs so embarrassing. Weโre a database server. We should have that. We donโt have anything about the total cost complexity of queries that are moving through the server because itโs one thing if I say queries per second and you think of like fast queries like inserts, updates, and deletes on a website, accounting entries, payroll entries, but then we all have that delicate flower over in the business intelligence department that runs a query that cross joins 40 tables together and next thing you know, one of their queries takes the entire server down. That personโs one query should be measured differently than one tiny insert, update or delete for a select for a web page, for example.
We canโt manage or monitor any of this. Itโs so sad. And at some point in the industry, we should probably talk being about being able to pull this off. We canโt do it in Azure SQL DB. We canโt do it in managed instances. We canโt do it in fabric. None of these things. If we did try to roll our own because right about now some of you out there are thinking I could roll my own with extended events you could but the overhead if you want to track every query and its duration is going to be staggering when you start to instrument that and you canโt write it to the same SQL Server that youโre monitoring you would have to stream that output out somewhere else and thatโs something that Iโm going to leave as an exercise for the reader some of you right now are thinking doesnโt query store do that doesnโt the plan cache do that? No, they do not. They do not capture all queries. Think queries with an option recompile for example. So the metric that we have to use, Iโm not happy about it, but this is all that we have, is a perfmon bond counter called batch requests per second. Thereโs a metric called transactions per second. You canโt use that because not every query is a transaction, but every query is part of a batch request. So, youโre probably asking what is a batch request?
You know, a stored procedure, how a stored procedure can have like five queries in it and then itโs got the word go at the end. A group of queries with a go at the end. And go is a SQL Server Management Studio thing. Other you could change it to something else if you want. Like if you want to be Patrick Stewart, you could say engage and you can change that in tools options under management studio. But all of those queries together are called one batch. That is the metric that we have to watch. And it sucks because of course not every batch is the same. Some batches are different than others. Some batches are bigger than others. But if Iโm going to look at one server for an extended period of time, I at least get the feeling that most of the queries on that server are roughly the same. Itโs not like the entire query workload changes every day. It doesnโt shift continuously from half the time itโs transactional and then half the time itโs reports. So then I want to trend it out on an hourly basis and I want to break it out by time of day, day of week. Brandon recognizes the Moresy reference there. I want to trend it out by whatโs normal because this is the first place that I go when someone calls in and says, โHey Brent, is there something going on on the SQL Server right now?โ The more queries youโre running per second, ideally thatโs because more people are accessing our website.
22:14 Batch requests in practice
Classic example from a client that I worked with got called in emergency. Theyโre like, โOh my god, SQL Server performance is absolutely terrible.โ And we go in and look at batch requests a second and itโs like 10 times higher than theyโve ever dealt with before. And Iโm like, โWell, yeah, of course. When you pass in 10 times more queries, itโs going to take longer to execute all those queries. Youโre putting in more workload than you ever have before. And we ended up finding out that there was a pricing error on their website. Somebody had accidentally priced a camera incorrectly. And so thousands of people from Reddit were piling in all trying to order cameras for 57. So of course that results in all kinds of problems. Another example where this goes a little screwy is think about a web page. A web page is a dashboard and itโs got several metrics on it. Every time that web page is opened up, your app may make several queries, one for each of those metrics. Well, imagine that they do a new deployment over the weekend and when you come in on Monday, there are several more metrics. That web page is longer. It has more dashboard dials in it. Well, every one of those probably represents more queries to the database. So you can see batch requests a second go up even when itโs the same number of users hitting the web pages or running the application.
In a perfect world, this number goes down when we start to do caching. We start to cache stuff in the front end. So whatโs normal? From zero to a,000 batch requests a second. Itโs easy to handle with commodity hardware. And remember what I mean by commodity hardware. Go to amazon.com. I have no affiliation with Amazon.com, but everybody knows Amazon.com. You Best Buy, wherever you want to go. Go look at laptops or desktops that cost about $3,000. If you can go buy a desktop or laptop that costs about $3,000, odds are a data professional can get that to work between zero and a,000 batch requests per second. Now, of course, remember we have the data warehouse people. Theyโre a totally separate animal. Iโll talk about them in a second. But when you go up over a thousand batch requests a second, it can be hard to handle. Hard to handle. Now, it can be hard to handle. I listen to music all day in the office. Who doesnโt? So, of course, Iโm constantly thinking of lyrical references. For over a thousand batch requests a second, it can be hard to handle. Now, even if youโre doing a really good job of performance tuning and to explain that, let me tell you a story about a friend of mine who worked for a payroll company.
Friend of mine, payroll company on a Monday morning. Heโs looking at his dashboard for SQL Server performance and heโs like, โOh man, we deployed a report this weekend and we really should have put an index in for that report. Iโm just going to go put the index in.โ Typescreate index. And of course is friend of mine working for a payroll company. Theyโve got lots of money. So he has enterprise edition. He can say create with online equals on. The index gets created. Everythingโs working great. But the index isnโt getting used. Turns out he had something wrong in the index. And heโs like, โOkay, no problem. Hold on a second. Iโm going to drop that index and Iโm going to go create another index.โ SQL does not have a drop index online. Has the create but not the drop. So he goes to do the drop and he hits execute. And that server on a Monday morning at a payroll company, there are a couple of things happening. People are clocking in and out. Theyโre clocking in to go show up for work on their Monday morning. And also managers are running reports to see how they were doing for payroll as for last week. Did they go over budget on payroll or did they do okay? And this server was doing 3,000 queries per second, 3,000 batch requests a second.
24:58 Why changes get risky under heavy load
So when this guy hit drop, the guy isnโt me. If it was me, I would have told you. I have no shame. But just so that weโre all on the same page. When this guy hits index, within 1 second, 3,000 queries are blocked. 2 seconds, 6,000 queries are blocked. 3 seconds, 9,000 queries are blocked. And the cluster fails over. I donโt know if youโve ever hit execute on a query and the serverโs gone down or failed over. If you havenโt, you donโt think itโs you. What happens is, especially if youโre in an office, all of a sudden people start popping up in their cubicles and theyโre like, โHey, is something going on on the SQL Server right now?โ And youโre like, โYeah, somethingโs going on. I donโt I this should be instantaneous. I donโt know whatโs going on and everybody starts to troubleshoot. SQL Server doesnโt make it easy to find out why the cluster failed over. It makes it extremely hard to find out why the cluster failed over. In fact, so this friend of mine along with all the other DBAs goes running into a war room. They try to figure out exactly what caused it. They canโt figure out what caused it. Thereโs SQL Server doesnโt track the lead blocker when the cluster fails over. Everybody goes back to their desk and this friend of mine settles down.
Heโs like, โOkay, so what was I in the middle of?โ Thatโs right. I was dropping an index. Hits execute and brings the SQL Server down again. When youโre up over a thousand batch requests a second, you canโt just walk up to the SQL Server and do something youโve never done before. You have to run it through several people to make sure that youโre not going to bring the SQL Server down. Now, everything that Iโve said so far is really about transactional servers. The way that you turn tune data warehouse servers is different. When you have these one ugly queries that can bring the entire SQL Server down, thatโs outside of the scope of this session because of course the complexity is much harder. But just know that you donโt measure it in terms of queries per second. Usually measure it in terms of total workload amount per second. So we got the first two numbers. Weโve got how big is our database and how fast is the database going. The next oneโs a little bit harder. And to explain it, Iโm going to think about the worldโs simplest SQL Server. Iโm going to imagine that our SQL Server only has just one CPU core and thatโs it. If you only have just one CPU quer CPU core, then one query picks up and starts running while other queries pile up behind it waiting to run.
28:58 Workload: wait time
SQL Server isnโt like VMware, HyperV, or Zen. SQL Server doesnโt have the concept of clock sharing. That query is going to run until one of three things happens. It finishes, it has to wait on something, or it uses CPU for four milliseconds straight. After four milliseconds, it yields the CPU to let someone else step in and take action. So, as a result, I care very much about whateverโs piled up in this right hand side waiting. When you go through my mastering classes, I talk all the time about this chart. Iโm like, okay, letโs think about whatโs in the right hand column in the waiting column in SQL Server thatโs waiting to get access to resources. And the resources that we could waiting for I one category resources you can kind of think of as anything that you would walk into the data center and put your finger on. So CPU, memory, the network card, the SSDs, whatever. Thatโs the resources column plus locks. Then thereโs stuff outside of SQL Server.
And the classic example of this is linked servers. If you do a linked server query, letโs say you ask me, โHey, go connect over to the accounting server and get todayโs payroll.โ Iโm going to say, โAll right, well, Iโm connecting over there, but I have no idea whatโs happening over there. I am preempted from being from getting any work done by that yo-yo over there. I donโt know whatโs taking that SQL Server so long.โ When it comes to preemptive weights, the answer is really easy. Stop doing that. Iโm not popular when I say that, but you shouldnโt be using linked servers. You shouldnโt be building Word documents on the SQL Server. You shouldnโt be shelling out and calling XP command shell. If you need to as a database administrator, thatโs one thing, but that isnโt something that we performance tune for. I donโt tune preemptive weights, but also itโs because customers arenโt usually complaining about that. Theyโre usually complaining about the first set of results there and they certainly arenโt ever running into my office saying Brent quick the lizy rider is slow I need you to tune that something thatโs system facing that happens on the back end users really compare complain about resource weights CPU storage locks network memory all of that kind of thing now we need to measure this we need to measure how hard a SQL Server is working.
Whatโs the number that Iโm going to use? If I imagine for a second that I have a one CPU, just one core SQL Server, and I have one core running right now, and nothing else is waiting behind it. Is this server working hard? Well, to be fair, maybe the restaurants tableโs really large. Maybe itโs a terabyte in size. And maybe weโve got a terabyte worth of memory and weโre able to cache all of those restaurants. This query could run for a while if we had to scan all of that data and while it runs CPU could be 100%. But letโs be honest, weโre not getting calls like that, right? Weโre not getting performance tuning calls like that because even if we were, who are we getting them from? Just one person running a query. We donโt have to go. Okay, Sherlock, you think the serverโs bad shape now? What are you doing to the server? And sometimes we get calls like that. What about now? We got a couple things piled up waiting. Is this server working hard? Well, itโs itโs working harder cuz as this thing finishes, we got more stuff piled. Okay, so what about this server? All right, now we got even more stuff piled up on there.
And what you really have to understand is that itโs not just about select from table because your queries out in the real world, itโs not select from table wear clause. These arenโt the kinds of queries that people are running on your system. Your users are running complex queries that join across multiple tables. And so what SQL Server will do automatically, letโs read this execution plan. Itโs doing a scan of this table and it went parallel across multiple threads. Itโs doing a scan of this table went parallel across multiple threads. Itโs joining their results together that also went parallel across multiple threads. It is normal on a busy single query SQL Server not to look like this. But even just for one ugly query, your single core can look like this. You can have for one query a scan running of one table plus multiple scans running across other tables at the same time. So when we think about a busy SQL Server, it is completely normal to see one thing running right now and several things or even several dozen things piled up in the right hand column.
We want to measure how much is in that right hand column, the waiting column. We want to measure how long theyโre there and what theyโre waiting on. Letโs pretend that our SQL Server looked like this for one second straight. If it looked like this for one second straight, how many seconds of weight time did I pile up in that one second? Now the query on the left hand side, heโs using CPU, so heโs not waiting on anything. Heโs churning away through all his data, doing whatever he needs to do. Heโs working. Heโs not waiting. But in one second, if we got all these things waiting, in that one second of time span on just one core, I have piled up 19 seconds worth of wait time. Iโve piled up 15 seconds worth of time waiting on storage, 3 seconds worth of time waiting on locks, 1 second worth of time waiting on CPU. It is normal on a busy server to see a graph that looks like this.
35:54 Reading the wait time graph
Every monitoring tool out there on the planet has a graph that looks exactly like this. This is the most important graph inside that monitoring tool. It says in the hours of Whoopsie. Come back over here. In the hour between 6 and 7, we had Hey, look at that numbers. We spent 15 hours waiting on storage. We spent three hours waiting on locks. We spent one hour waiting on CPU. Thatโs exactly the same as the graph we just saw, the table we just saw here. We basically had during the span of that hour, we had 15 tasks waiting the whole time on storage. We had three tasks waiting the whole time on locks. We had one task waiting the whole time on CPU. When you see stuff piled up like this, the higher this number is, the harder your SQL Server is working. Whatโs so important is that these two things, the unit of time down here and the unit of time going up here have to be the same. Every monitoring tool on the planet does exactly what your project manager would ask you to do.
Hey, can you automatically size this graph so people can always see peaks and valleys because you donโt want to go open a monitoring tool and have all the things be right down at the bottom. Youโd be like, โThat doesnโt make any sense. You need to zoom in so I can see it.โ So, every monitoring tool on the planet resizes these on the fly so that you can always see things. And hereโs the part that sucks is that some of them will put minutes down here and milliseconds down the left hand side. Some of them will put 15 minute bars going across the bottom and like minutes on the left hand side. So, you wonโt really know that in a 15minute time span your server only waited for three minutes. It was bored. It wasnโt doing anything. Or in the example that I had from a client now, normally when I work with clients, I make them send me diagnostic data. I get have them send me a bunch of data over so I can see what Iโm walking into and that I can sometimes just give them advice and tell them, hey, you need to do this and your problems are going to be gone. But long time ago in a galaxy far far away, I didnโt ask for that every time. And so I had a client call me up, I need you to get on the plane right now and go to Missouri. So Iโm like, okay, as it happens, Iโm free on Thursday, so Iโll go down there.
38:29 A client story: when the graph isnโt the problem
So I hop on a plane. I fly down Thursday morning. I show up in this office in Missouri. And they say, you can see right here, we got these peaks on the graph. Performance is really bad. And it had hours going down across the top bottom. And on the left hand side, it said milliseconds. So, like in the hour of 8 a.m., the whole entire hour of 8 a.m., their server had been busy for like 27 milliseconds. I was like, โlet let me explain to you how this milliseconds thing works.โ Like, but itโs still a peak. Isnโt that bad? Iโm like, well, watch this. I went over the console dbCC check DB and hit execute. And wab boom. All of a sudden, the bar just exploded up super high and everything that theyโve been worried about was flat right along the bottom. I said, โYour SQL Server can do a whole lot more than this. It is bored out of its core.โ And I said, โWhy donโt you show me what the users are complaining about?โ And so we go over to one of the users machines and their CPU is stuck at 100%. Because this application that was coded in Java was doing stuff for every row that it brought back for SQL Server was doing all this CPU intensive stuff and it was stuck on just one CPU core.
Their app didnโt multithread at all. I said do me a favor, take that application, go run it on one of the faster, you know, here, go run it on another laptop thatโs like more modern and has faster CPU cores. Theyโre like, oh, itโs so much snappier. I said, okay. So, the mystery is solved right there. And it was like 9:30 in the morning. I said, โ So my work here is done. You donโt have a SQL Server problem. I said, well, but itโs we paid you for two days and we paid all this travel. And Iโm like, do you want me to make it look harder? Do you want to be like, I need an hour or two to figure this out? Itโs so hard. Let me just slave over the hot keyboard for a while. And theyโre like, no, get out of here. And so I ended up eating some really nice barbecue in Missouri. But really wish I could solve problems instead. So when youโre looking at these, make sure that theyโre in the exact same units of time. This data comes from cydmos weight stats and it is stored in the worst way that SQL Server could possibly store it. Itโs stored cumulatively. So if you go query it, it just gives you the total amount of weight time since startup, but it doesnโt let you break it out by hours of day. You want to know whatโs happening on Mondays and Tuesdays and Wednesdays.
You donโt maybe donโt care as much about weekends or you donโt care about us overnights or you donโt care where when your backups are running. But we need to trend this out in a more granular way because this is how when weโre doing things like job scheduling, how we figure out to do play the little game of Tetris where weโre going to slot in our backups, where weโre going to slot in our check DB, where weโre going to slot in our index maintenance, where weโre going to slot in the data warehouse nightly loads, things like that. When wait time goes up, this is your failure graph. Something has gone wrong. When wait time goes up, when wait time goes down, itโs your success graph. It means that you did things well. Letโs go back to what we were seeing over there from that monitoring tool. So, letโs say that this is A.M., 6 a.m. 7 a.m. 8 a.m. 9:00 a.m. 10 a.m. 11 a.m. You can see that something after 9:00 a.m. The wait times on storage dropped a lot. Not by a little, but a lot. All of a sudden, we stopped waiting on storage. Now, if there were not 258 of yโall in here, I would have you put over into chat what you think might have caused that. But we will get an avalanche of ideas because yโall are all so bright and attentive and not to mention you smell much better than you did yesterday.
So what happened? So Zu, for example, says data got cached up into memory. Yeah. So maybe somebody restarted the SQL Server at 1:00 a.m. We had an empty buffer pool and then as things came up into memory, we didnโt have to wait on them for storage anymore. Other ones. Letโs say that the backups finished, the overnight backups finished, our scheduled reports finished. And itโs funny, Eban just said backups finished. Letโs say that somebody stopped doing things on the sand that we used to have noisy neighbors on the sand that were all competing with us. Dan says maybe we were doing check DB. There are all these answers coming through in chat right now. You know what nobody said so far? Tuned an index or tuned a query. Oh, you didnโt think of that, did you? Because you donโt do that, do you? Because you need to go to my classes, donโt you? This is your success graph. When you do a good job of tuning an index, tuning a query, your weight times will go down. SQL Server wonโt have to work so hard in order to satisfy your queries. Eban says people donโt do that in production.
43:43 What normal wait time looks like
That thatโs I have plenty of stories about that. Thatโs very true. So whatโs normal out there? So letโs see here. Chris Chris typed in a two-page long thing. So just as a reference here, I would love to stop and read your love letter to grandma. And Iโm sure itโs absolutely thrilling and interesting, but youโll forgive me, of course. Do you have more words in your question than Iโve had in total on my PowerPoint so far? That is impressive. I can only assume that you were typing for the last five minutes there into that chat box. I feel for you. Thatโs absolutely terrible. But maybe instead of typing so much, you might want to tune in. Always amazed that anyone ever attends my webcast twice, but Chris is laughing along with me. So how much is normal weight time ratio? If your wait time of is zero. And so what I mean by that is in a in a one hour time span, you donโt even have one hourโs worth of weights, your serverโs bored. That doesnโt mean that every queryโs running fast, but it means you donโt have a server problem. It means that if your wait time hasnโt even risen to one yet, it means that you want to turn around and ask the people complaining, โShow me the query that youโre having a problem with, and Iโm going to have to tune your query rather than looking at some holistic thing across the server overall.โ If in every second of time you have one second worth of weights, or in every hourโs worth of time, you have one hourโs worth of weights, now the server is doing things.
Itโs actively waiting on stuff and you want to look at what itโs waiting on. The higher that number goes, the worse shape your server is in. I get clients who call me when their weight times are in the hundreds, as in in any given hour, they have hundreds of hours worth of weight times, and Iโve seen them much worse. So now you have your three metrics. Your three metrics. Whenever youโre asking questions about your SQL Server or when you start troubleshooting performance on a SQL Server and you want to know if things have gotten worse or better, you want to know total data size, batch requests per second, and the wait time ratio for every hour on the clock. How much how many hours of wait time do you have? The easiest, quickest way to get started with that is with a stored procedure SP blitz first. And when I wrote this, I wrote it because I wanted it to be literally the first query that people ran when they were having a performance emergency. So, we itโs totally free over at the first responderkit.org. Thatโs the GitHub repo where you can go download it. It installs in the master database. You can put it in other databases. I just put all my diagnostic stuff over in the master database. Sometimes youโll hear people say you should never put things in master.
46:32 Audience questions
But the reason behind that is just because in the event of an emergency, you donโt usually restore the master database and you donโt usually back it up on like a transactional basis. You donโt back it up every hour or anything like that. Well, I donโt care about utility scripts. Iโm just going to script them all out from GitHub anyway. So, itโs not like I care if I lose them. Iโm probably on an older version anyway. So, by default, it shows your weight stats for a 5-second sample as of right now. So, when I go execute it, it gives me a prioritized list of here are the things that we think are causing SQL Server slowness right now. And it doesnโt start a profiler trace, doesnโt start an extended events trace. Hereโs all it does. It takes a snapshot of a bunch of tables like system tables, weight stats, perf, mod counters, waits for five seconds, takes another snapshot, and then compares those two snapshots to tell you whatโs been happening on the SQL Server right now, what its CPU usage is, what its batch requests have been, what its weight time has been, and then it gives you this prioritized analysis of what it thinks is going on. Itโs my favorite result set from it.
No problems found. Because I donโt know about you, but on Friday afternoons, I like to stop working. Itโs one of my favorite things about my job is walking out of my office and not working anymore. And inevitably what happens is you end up starting to drink or whatever substances you choose to use or play video games or assemble Lego or whatever it is that you like to do and then you get the call from the help desk. Itโs like somethingโs broken on the SQL Server right now. Can you take a look? I got sick and tired of hearing that. And Iโm like no. How about you take a look? Go run sp_BlitzFirst. And thereโs instructions in there about how to give permissions to even help desk users so they can run this. How about you go run sp_BlitzFirst? Whatโs it say in there? It says no problems found. Oh, do you know what that means? It means that there were You donโt care, do you? Youโre going to make me come in anyway, arenโt you? But at least then I know itโs not a high priority issue. Itโs not something that Iโm going to face a, you know, flaming trash can of problems when I get in there. Whereas what it typically looks like when itโs under load is it gives you a prioritized list of hereโs what is on fire right now.
Thereโs a poison weight, thereโs high CPU, whatever. And you notice that it has those metrics that we just talked about. This is like our SQL Servers dashboard. It tells me the number of batch requests a second that Iโm doing right now. My weight time, excuse me, weight time per core per second and my total database count and database size. So I can see right at a c at a glance exactly whatโs going on on that SQL Server there. But also tells you all kinds of other things. Is there a longunning query thatโs blocking other people? Is there a backup thatโs running when it shouldnโt be running? Did somebody just erase the plan cache? Should a bunch of stats just get updated? And so forth. And in the free training classes for it, I teach you how to use all kinds of other parameters like how to analyze your weight stats since you started it up, how to log the data to table, and so forth. But what this is is itโs a right now tool. Itโs whatโs happening as of this exact moment. Do getting these three numbers. Total database size, batch requests a second, and total weight time per second. This is just like the training wheels. These are the first minimum three things that you have to know. What you really want to know is you want to trend them over time. You want to see what they look like on Mondays, usually what they look like on Tuesdays, what they look like after hours.
Plus, that way when youโre you come into work on a Monday and someone says, โWhy was the SQL Server slow on Saturday overnight?โ You want to be able to open up a monitoring console that can tell you that. Well, just like I wrote the first responder kit, Eric Darling has written this performance monitoring tool. Itโs a totally free open- source performance monitoring dashboard where you can track metrics just like this plus lots others blocking the plan cache all kinds of things. Even gets data from query store. Highly recommend it. Itโs entirely local. Just keeps all the data locally on your own servers. Doesnโt even need a SQL Server data repository in order to work. Can run directly on your laptop or can run on a jump box in your environment. So, to recap what we talked about inside here, this is the Aerial Atom, that car thatโs super lightweight and has no windshield. When Top Gear reviewed it on the BBC, Jeremy Clarkson said, โItโs so fast it warps your face.โ Because, of course, in order to be funny on TV, he drove it without a helmet. You can see what it did to his face. Tuning is all about these three metrics. Total database size, batch requests a second, and wait time ratio. Those three metrics are how you figure out whether youโre dealing with a big server or a small server.
51:42 Recap: capturing the three numbers with sp_BlitzFirst
And the answers that you get when you ask questions online will be dramatically different based on those three attributes about your SQL Server. You capture those metrics with sp_BlitzFirst for like real-time diagnostics or Eric Darlingโs performance monitor for longer term analysis and whatever your top weight stat is. Thatโs where you should focus your tuning. Donโt worry about disc q length. Donโt worry about buffer cache hit ratio. Donโt worry about page life expectancy. All of those numbers lie extensively. If I had more time on the webcast, I would show you examples of how all of those things lie. They will tell you that you have a performance problem when you donโt. They will not tell you when you have a performance problem when you do. So, look at your top weight stat. That top weight stat is what you start narrowing down and reducing your performance problems. That is everything that I wanted to talk about with yโall today. I hope that yโall had a great time and learned something. Round of virtual applause for Jam Software for sponsoring todayโs webcast. They did this for yโall because they love yโall. Not like me. I donโt like any of you. Not entirely. True there.
All right. So, thanks. Hopefully, yโall had a good time. And I will see yโall in one month. U, we are doing another webcast. Let me go look and see where it is. Iโm going to go pop it up on my calendar. Iโm going to pause sharing because I donโt want you to see how bad my calendar is right now. It is I know itโs in September. It is September 17th. September 17th. I have another one. Why you shouldnโt use SQL Agent for batch processes. And I know thatโll be fun for a lot of yโall. So, thanks everybody from Jam Software. And thanks yโall for attending. I will see yโall in the next one. Adios yโall.

Your SQL Server Toolkit Just Got Bigger
Now that you know how to measure your SQL Server's health, put that knowledge to work. Here are two free tools to help you go further.
Windows Task Scheduler Diagnostics Script
Instantly audit your Windows Task Scheduler jobs and catch problems before they catch you.
JUMP Migration Tool for SQL Agent
Migrate off SQL Agent fast, without manual rework.
See your own jobs run in JAMS Scheduler.


