The SQL Server Performance Tasting Menu: How To Manage Buffer Pool Space With Better Indexes

The Water Is Fine


Video Summary

In this video, I delve into the intricate world of SQL Server performance optimization, focusing specifically on how better indexes can enhance your buffer pool utilization. The buffer pool is a critical component in SQL Server’s memory management, serving as the cache for data pages from tables and indexes. It’s essential to understand that while many sysadmins or VM admins might allocate memory to SQL Server without deep knowledge of its needs, proper index management can significantly improve overall performance by reducing unnecessary maintenance and ensuring efficient use of the buffer pool. I also touch on how unused indexes can lead to increased blocking and wasted resources, emphasizing the importance of regular index consolidation and cleanup as part of any database tuning process.

Full Transcript

I’m working on my performance art. That’s me cutting myself off from the world. I’m going nowhere as an artist. So this video continues along the Steam tradition of SQL Server Performance Tasting Menu videos in which I show you some crazy kooky little thing about the way SQL Server works without much of a narrative or without much of a story to back it. And in this video, which, I don’t know, may exist somewhere, may exist in other places, I don’t know. Who can tell anymore? It’s a crazy world. There’s probably a deep fake of this video somewhere. In this video, I talk about how better indexes can help you make better use of your SQL Server’s buffer pool, which is always a good thing to do because, you know, a lot of people, when they give memory to SQL Server, they’re idiots. They might be, I don’t know, they might just be sysadmins or VM admins or just come from a non-SQL Server background. They’re just not well tuned into how how SQL Server uses memory, how necessary memory is for SQL Server performance, and things like that. So the three things, the three places where SQL Server uses memory most that people will care about are the buffer pool. That is where you cache pages, data pages from your tables, your indexes, so that SQL Server can access them for different activities. Doesn’t matter if it’s a read or a write, any page that you need to deal with needs to end up in memory.

Beyond that, SQL Server also, as we have learned in the past couple few videos, needs memory to give queries for query memory grants. And those query memory grants can grow quite sizable. In the last video, we saw a 9.7 gig memory grant for just selecting the top thousand rows. That’s a pretty good chunk of memory, almost no matter what kind of configuration your server has. The third thing is the plan cache and a good, stable, reliable plan cache can really, really be useful. I wouldn’t, I won’t say for SQL Server performance, even though it can be, but a good, stable, reliable plan cache can be really useful for SQL Server performance investigations, where you can go and dig in and look at resource intensive queries and other things like that. So with that out of the way, let’s look at how we can make better use of our buffer pool. At some point, flush them back to disk transaction log stuff, boring, has nothing to do with query performance. So I don’t, I put that out of my head. I’m kidding. It’s all very interesting.

So having a lot of unused indexes can also be a problem because not only do you have more things to lock when you modify the table, you know, more blocking, things like that. But you also need, you also end up sort of polluting the buffer pool with those additional indexes that will never help a read query, but need to get maintained when we modify the base table. So, so please, whenever you’re tuning indexes, don’t forget to make index consolidation and cleaning out unused indexes part of that process.

Just adding indexes will often end up causing problems over time. It’s something that I see constantly when working with clients. And it’s something that I like almost always have to hand over a big long SQL file of changes to indexes.

Like you drop out all these, I’m going to merge these in together. We’re going to make one index instead of having five different indexes that are almost the same definition because stuff like that hurts RPO and RTO too, right? And with the longer, the more indexes you have, the bigger your databases and more stuff you have to back up.

When you need to restore a database, there’s more data size to restore. And it’s just, you know, it’s all, it’s all ends up not being good for many different, many different metrics that you can measure with your SQL Server. So thank you for watching.

And we’ll see you over in the next video where I will talk about something else that I haven’t quite decided on yet.

Going Further


If this is the kind of SQL Server stuff you love learning about, you’ll love my training. I’m offering a 25% discount to my blog readers if you click from here. I’m also available for consulting if you just don’t have time for that and need to solve performance problems quickly.