Streaming Week: BIT obscene

I Like Questions!


Video Summary

In this video, I found myself navigating through various challenges and learning moments. Initially, the technical issues with PowerPoint and SQL Server tools like SQL Prompt took center stage, but as we hit the live stream’s 15-minute mark, things began to settle down. The community started to engage more actively, and it was a delightful shift from being the one asking questions to having an audience ready to share their expertise. The discussion around querying XML versus JSON highlighted some interesting points about how Microsoft supports these data types in SQL Server. While JSON is gaining traction, XML remains deeply embedded in many core functionalities of SQL Server, making it a more necessary evil for certain tasks. The conversation also touched on spools and their limitations, with a particular appreciation for the window aggregate spool as highlighted by Coyote McD. Overall, the stream was a great opportunity to both learn from others and share my own experiences with SQL Server.

Full Transcript

Thank you. Thank you. Thank you.

Do-do-do-do-do. Do-do-do-do. Do-do-do-do. Everyone can see me trying to hastily figure out how to get this slideshow working the way I want it to. For some reason PowerPoint is fighting me at every turn.

Constantly fighting me. It’s fun. It’s so much fun.

I am fun. I am so much fun. I wish I was more fun.

I am so much fun. I wish I was fun like I used to be fun. Well, that’s sort of working. Yeah.

Woo-hoo indeed. So that’s just happening way too fast. That is aggressively fast. I don’t understand what… Hang on. Make sure that’s safe. Let’s try that again.

No, that’s way too fast. Well, what are you doing? I don’t know. That’s five seconds, right? 05. Let’s try it for… I don’t know. 20?

Maybe 20? I use Excel instead of PowerPoint. Yes, if only I had… No. What are you…

This thing is bonkers. All right. Let’s… Oh, I’m not recording this one.

So you have to stay. I suppose I could record it. I do have a record button. But I’m going to wait…

Timing? Uh, I’m going to wait and see… I’m going to wait a couple minutes because right now I have… I have two eyeballs, but… Without some more eyeballs, I don’t know what I’m going to do.

If you want the slides to advance using the same speed, click Apply to All. Apply to All. Transitions.

Good morning. Good morning, indeed. The beautiful people are here.

My goodness. My goodness. What am I going to do with all of you? You’re all too much… You’re all too… You’re just too much better looking than me. It’s painful.

All right. Let’s see. Do I… Do I look normal? I do look normal. Wow. I do look normal. Great. What time zone are you in?

I am in… Eastern Standard Time. It is… 11.05 AM. As God intended. I am streaming head to head with Brent.

Oh, boy. I am streaming head to head with Brent. Well, can’t win them all. I think he saw me tweet yesterday that I was going to go live and he decided to sabotage me, I guess.

His ended. Whew. Well, I got lucky then. All right. I take it all back. He did not decide to sabotage me. Well, I hope he wrote a really great post while everyone watched.

I hope it was life fulfilling. I hope everyone learned something. All right.

So, the purpose of this here… Well, this isn’t slideshowing at all. This is doing the opposite of slideshowing. This sucks. I don’t understand why…

Is that minutes? All right. Let’s do that to zero. I think that was 20 minutes. Let’s try this at 10 seconds and let’s apply to all. And now let’s… Let’s see.

I’ve been putting your stickers all over bathrooms in Columbus. I hope that you use the ones with my phone number on them. And preferably the ones with my headshot. Because those are the ones that are the big draw in bathrooms.

Zeus, once again, this is something you have to fix on your end. There’s buttons where you can adjust the quality. I’m not going to stop streaming in 1080p.

Because you can’t push a button. I’m sorry. If you need to watch it later, if you need to watch the recording later, I totally, totally understand. But that is on you to do, my friend.

You’ll have to take a heroic action of Zeus-like proportions in order to look at a lower stream. He seems famous, but who is this Brent? Well, Brent is someone who can figure out how to get a slideshow to play on repeat.

So that’s nice. Slideshow. Let’s see.

From beginning, custom, or it’s record. I don’t want to record. I just want you to… I want you… Loop continuously until escape.

That is beautiful. That is what I want. There we go. Let’s try this all over again. Let’s also turn this down from 10.

That might be a little excessive. Apply to all. Yes.

Yes. Yes. Yes. There we go. There we go. Now we’re cooking.

Five seconds seems a little fast, though. I’m going to get this one day. In the meantime, if anyone has questions about SQL Server, you know, general fun… If anyone wants…

How about this? If anyone would like to tell me what it’s like to be able to go to gyms or restaurants or bars or enjoy being outside, I would also appreciate that. I would watch that stream.

I would watch that stream happily. Happily watch that stream. Food is amazing.

I know it is. I know. Food is wonderful. I remember when I could eat food. But now I’m old and gymless and thinking about calories seems to make me fat. Say something nice about querying XML.

You sure do it a lot. The nicest thing, Michael, about querying XML is knowing that I am in your good company. That is the nicest thing.

Have you done a stream on human events? I have… So, over on YouTube, I have a bunch of recorded stuff about SP human events. Underscore.

Thunderous underscore human events. And earlier this week… Geez, time is so… Fungible. Right now. Yeah.

I think earlier this week, I did a quick live stream of working through a few issues in SP, thunderous underscore human events. But I haven’t done one on using it. The only reason that I haven’t done one on using it is that a lot of the times, getting the demos set up to properly show you how things work is a little time consuming.

You know, you got to create indexes and, you know, set up the blocking and all this other stuff. So, I mean, it would be…

I would have to… I would really have to figure out a way to streamline it in order to make that sort of a compelling stream to walk through it. You know, it’s not like a monitoring tool where you can, like, pre-bake all the data in there and then just click around through it and be like, look how awesome it is.

But, you know. I’ll work on something because that is a fun tool. That is a fun one.

Let’s see. Are there any SSMS plugins you would recommend? Geez. I don’t really use… I don’t really use anything.

I guess the biggest one for me is SQL Prompt. And, you know, I love SQL Prompt for like a very specific few things. But, you know…

And it’s not like I think it’s a bad tool, but man, like the more stuff they add into it, the more things just get very, very strange with it. And there’s also a lot of stuff.

There’s like these shortcuts in SQL Prompt. And if you are in the middle of typing something else and you accidentally auto-complete a shortcut… Yes, Red Gate stuff.

If you accidentally insert a shortcut and you try to hit Ctrl-Z to get rid of it, it won’t Ctrl-Z and leave. You have to like stop and then like delete this whole script that popped up to like create an index…

Create a user or create an index or something. It’s very strange. The one that lets you search schema. Fortunately for me, I only have one schema. So, I don’t really need to…

I don’t really need to search through too many of those. There’s like 10 tables in it too. It’s wonderful. I have almost no searching to do. Double escape would allow to Ctrl-Z out of it.

Yeah, but it doesn’t… As far as I know, that doesn’t undo the text that just popped up on screen. But you know what?

I’m willing to try it. So, let’s see if I can recreate this fiasco. Let’s go into SSMS. Let’s see if I can figure this out. If you…

Because if you have a solution for me, I will… I will give you all of the free streams for the rest of your life. You will have all of my streams for free. My family and I will be eternally grateful.

Let’s not recover that. Let’s start with a new one. Start with a brand new. Brand new. Well, I didn’t…

I didn’t really want you to show up. But here, we’ll start with this one. We have many things going on. Many, many things. You can all see SSMS, I take it. And you can all see the fact that I have SQL prompt installed.

So, let’s buy ourselves a little real estate over here. And let’s say… Well, let’s use a database that has something useful in it. Let’s say use stack overflow.

And let’s say create index whatever on. And then… Where I usually get messed up is with something like this. So, this is a good example of…

Of a shortcut script that they have. Where if you type in… If you type in C or whatever, You’ll get this thing where it says create clustered index. And they have this weird thing in SQL prompt now.

I’ll show you that afterwards. But let’s say that I hit tab to auto complete that. I get this whole thing, right? And if I hit control and Z. Which you can’t…

You can’t see me hitting. But I am furiously hitting control and Z right now. That doesn’t go away. So, I’m going to see if double escape actually does it. No. So, I’m hitting escape all over the place.

And I still can’t get out of what this thing just popped up. So, control Z doesn’t do it. I have to go and delete it. It’s very, very strange. Right?

Very, very strange. So, that’s fun. Wait, maybe that did work. Let’s try it again. Ooh, so the… Oh! Double escape then control Z. There we go. Alright.

Now, see, thank you for solving that problem. I will now give you a lifetime membership to my free live streams. That is wonderful. That is wonderful.

That is wonderful. I’m glad we have that cleared up. Alright. Let’s get back into… Let’s get back into our slideshow. It’s enough management studio for one day.

Apparently, this is a live stream where I ask you… I ask you all SQL Server questions. And you give me answers. This is great.

This is totally just turned the tables on you. Now you’re all the live streaming stars, right? Beautiful.

Beautiful. Alright. So… What I’m gonna do… Is since we are about 15 minutes in, we have a decent spray of people in here. I’m going to hit record.

I’m going to hit record. And… We will begin. We will begin with things. Now that I have PowerPoint figured out, and I learned something new about SQL Prompt, I feel like…

I feel like we’re in a great spot. We’re in a great place today. You and me, all of us. We’re in a great place. So… Who wants to ask questions about SQL Server? Who has questions… Of any kind?

Really, I’ll take anything. What do you think is worse? Querying XML or querying JSON?

Yes. So, I think… You know… JSON is a tough one.

Because… I don’t… I just haven’t… I just haven’t had to use it a lot. So, it’s really tough to say.

I don’t… Like, when I look at JSON, I’m like, I don’t mind you. Like, looking at it. But, you know, when also at the same time, like… You know, for all the talk that Microsoft has about like, JSON’s the future.

We got all this JSON. We got all this JSON stuff. We got JSON, JSON, JSON. We support JSON. You know, it’s like… Nothing that they use internally is in JSON.

Like… Like, query plans are still XML. All the extended event crap is XML. The DTS package stuff is in XML. The way that SQL Server Server’s maintenance plans is still in XML.

And I got… Like, that’s just never going to change. So, for me, like, natively working with SQL Server, I just have to use XML. If I don’t use XML, I got nothing.

Right? But if I… Like, JSON, it’s just like, you know… I just haven’t run into anyone like… Eric, we have a tough JSON problem. But, boy, oh boy. Do I run into a lot of people who are like, we have an XML problem.

Like, I don’t know. Are they just behind? No. They just got support for JSON in 2016. And, like…

How can you, like, fundamentally change query plans and extended events and all these other things? And… Like, you can’t backward… Like, just automatically make, like, SQL Server versions going back over a decade.

JSON compliant. But I don’t know. Like, I just have to use XML for stuff. I find myself having to use XML.

But I don’t find myself having to use JSON. The one thing that I would say I think JSON really wipes the floor with XML on is around indexing. So, like, you can have a…

Like, at least the last time I messed with it, I remember that I could have a computed column that was like a JSON expression. But you can’t have a computed column that’s an XML, like an XPath expression. You have to create a scalar valued function and put the XPath expression in there and then you can do it.

But then you have a scalar valued function in a computed column and you break so many other things on your table. And, like, I see people offer this as a solution on, like, blogs and other stuff quite a bit. And I’m like, that’s…

Like, with no warning. With no warning about all the other terrible things that can happen. They’re just like, eh, you can totally do it. Go ahead. Go crazy. Coyote McD.

Coyote McD. I’m sure you are a pretty coyote. Ask, what’s your favorite spool? The window aggregate spool is my favorite spool. That is the batch mode version of what windowing functions use.

And I think that’s my favorite one. All other spools must die. I hate them all.

I don’t hate them. They’re just, you know… They don’t keep up with the times well. There’s, like, some very important optimizations in TempDB that spools don’t… Stools aren’t…

Stools aren’t governed by. Like, and I know Paul White has mentioned a few times that, like, some of the work that spools do behind the scenes is row by row. So, like, there’s no, like, bulk loading into spools, I think, or something like that.

But, yeah, it’s, you know… Like, I understand why they’re there. I understand the point of them. I just wish that spools would get the kind of optimization love that, like, the rest of the SQL engine has gotten.

And… And… Alternately, or alternatively, depending on how much plaid you wear, where in the country you live, I hope that as SQL Server moves into the future…

And I know this is a tough one, because so many people are going to be stuck on older versions for a while. Uh, whether it’s vendor lock-in, lazy, like, you know, lazy places of business or whatever. But, uh, SQL Server 2019, which at some point will be an older version…

At some point, SQL Server 2019 will be the older version. Uh, I think that accelerated database recovery is going to, um, hopefully… Hopefully offer some engine improvements where we could get rid of spools.

Because the way it works… And accelerated database recovery is really cool. Like, I was… Like, uh, my friend Forrest has a blog post about it. Uh, let’s see if I can…

I’ll go find that. And… Because I want to show that to you. And I… I believe… At least the last I checked, uh, Google Chrome is safe here, because I don’t have it synced for anything. Uh, but let’s just check, uh, Forrest McDaniel Acceler…

Oh, I did that all wrong. Data… Database…

Uh, recovery… I apparently need recovery. But, yeah, there we go. So, the nice folks at Redgate, uh, had my friend Forrest. And Forrest, I want to point this out. Um, Forrest, if you…

Like, let’s… Let’s… I want to open this image in a new tab. And I want to show you… This is Forrest. Forrest is the nicest human being on the planet. For…

Like, I have no business being friends with someone this nice. He is the sweetest person that I know. He also looks like a very young Connor Cunningham. So, what I want to do is, uh, show you Connor Cunningham. I think Forrest might be Connor Cunningham’s, like, illegitimate son or something.

Uh, but let’s just look at Connor Cunningham’s SQL Server. Where are our images? There we go. Where is a nice… Where is a big picture of old handsome?

Let’s get him up there. Get up on the screen. Come on, don’t be shy. Let’s open image in new tab. Let’s zoom in. So, I think Forrest and Connor could be related. I think there’s, like, a definite, definite chance.

They even have the same bangs. It’s amazing. I think there’s a definite chance that there is, like, some shared lineage here. Like, I think they could be the same person.

They could be… They could be family. Right? Look at that. They could totally be family. But, uh, Forrest wrote a great article on accelerated database recovery, how it works. It’s over on Redgate.

Let me stick the link into chat for everyone. There we go. You all have that. You can read that at your leisure. Don’t start reading it now, because you won’t pay attention to me. And, uh, well, you don’t have to pay attention to me anyway.

You miss relatively little paying attention to me. But, um, yeah. So, uh, accelerated database recovery is very cool. And what it…

The way it works is, uh, it takes the, uh, the tempdb pressure out of opt… Like, when you have… Normally, when you have an optimistic isolation level, like recommitted snapshot isolation or snapshot isolation, all of that stuff goes to tempdb.

The rows get versioned to tempdb rather than in user databases. With accelerated database recovery, we have what’s called a persistent version store. And the persistent version store is local to the user database.

And what’s really nice about that is that when you have a version store, when you’re keeping committed, like, like, you know, in terms of transactions in flight in this persistent version store to allow, like, very quick rollback, you also do a lot of the work that spools are doing.

So if we think about what spools do either by, you know, um, like, uh, for Halloween protection, having a certain set of rows, uh, available to read from, like, like, we, we spool, we, uh, we take, uh, we take rows that we’re going to modify, and we spool them to tempdb.

Uh, and we read from that, that source of rows rather than just reading the base data over and over. So we don’t run into, like, weird race or loop conditions where we keep, keep reading the data and, like, accidentally updating the same rows over and over again.

Uh, so if, like, having that stuff local, we could actually re, like, replace needing to spool the tempdb with the data that’s in the persistent version store. Um, so I think that’s, you know, that’s, that would be a really cool use of the feature, uh, which means that it’ll never happen.

Anything that I think would be a, is a good idea for accelerated database recovery or for anything in SQL Server, it means it’ll never happen. It will never get implemented.

Like, my best idea was if you have an eager index pool, you should get a missing index request for it. Nothing. I’ve been saying that for years. What did I get? Nothing. Book kiss. No one listens to me.

Let’s see. Chris asks, in a Greenfield project. Ooh. I don’t know. I did it. I think I did it a girl with the last name Greenfield once.

She was nice. She was from Long Island. Uh, would you go for 2019 with the latest compat level or something else? Uh, yeah, I probably, I would probably go with, uh, two.

Yeah, I would probably do that since then. Like you have nothing to compare it to. I would probably do that. And, uh, at the very least you would be able to properly prepare your workload for, uh, all the cool new optimizer stuff that SQL Server 2019 has.

Um, you know, you would be able, like if you don’t have legacy code that might just blow up in your face, you know, you can, you can really, uh, like starting fresh is where I would definitely want to do this in the same way that, you know, when people ask, you know, about starting fresh, uh, fresh application, like for a fresh, you know, absent anywhere, you know, like, I think really that’s, that’s where, you know, if you want to use like Azure SQL DB or something to take all like the sort of management crappiness out of SQL Server, that would be, that’s good for it.

Azure SQL DB doesn’t like, like, like back fit to a lot of existing applications. And it doesn’t because it takes a lot of the really crappy features out. Like a lot of like the, like those awful, like I’m a developer, I see a squirrel buttons that they want to press to do terrible things with SQL Server with, and then cry about performance later, Azure SQL DB is just like, no, you can’t do that. Nope. No, you can’t do it.

No, you can’t have that here. Nope. Sorry. You’re cut off. You can’t do it. So there’s a lot of reasons why I like Azure SQL DB because they’re just like, you can’t do that here. You know, we don’t want you here. You’re not allowed.

Uh, so like, I like the way that it limits people and like sanity checks them. It was like, but I want to do this. I’m like, no, no, you can’t. It’s not allowed. So I like that about it.

Uh, yeah, Chris, but look, Stack Overflow, they are a bunch of very, very smart, smart kids. They are very, very smart. They are like just incredibly gifted, smart, talented developers. But what they remind me of is when like, like the gifted class at your school, when they would allow them to like have a day without a teacher and do their own thing, they just don’t have anyone saying no to them. They do a lot of crazy stuff behind the scenes that most people wouldn’t normally do.

They do a lot of stuff at scale that most people just wouldn’t normally do. They do crazy and thing, insane things in the background. And a lot of, and a lot of the stuff they’re hitting is a result of that.

A lot of the weird edge case stuff that they do and they’ve done is a result of that. So it’s not stuff that I think most people are going to hit or see with SQL Server 2019. I think that a lot of the people who start, who start using SQL Server 2019 from scratch and are able to, you know, or, you know, hopefully have some sanity checks in place about what they’re doing aren’t just aren’t going to hit the problems that Stack does.

Like, you know, I, I love them. You know, Nick Craver is an incredibly smart person. My friend, my, my, my dear friend, Taryn, who is not just a gifted DBA, but also a gifted woodworker.

She makes the most beautiful cutting boards I’ve ever seen. Like they, they do, they’re, they’re great. They’re fantastic.

But man, like they have a very, very tough, tough infrastructure to manage and to deal with. And the scale that they’re at are just not what most people are going to be at. Like if you like, like, if you want to talk about web, web scale, Sack overflow is web scale.

Like they are, they are big. They are burly. And, you know, um, well, I, I, I sympathize and empathize and every other thighs. I mean, not, I mean, maybe not my thighs, but lots of other thighs is, uh, with what they’re going through.

Cause it, it does suck. You know, it’s like a lot of people that aren’t going to be there. Um, this, they’re not going to hit that point, not going to get that big. So, I mean, I wish you all the, I wish you that all the continued success in the world that you will get that big, but I don’t know that you’re going to get that big, at least big enough to hit stack overflow problems.

Cause like, you know, it’s crazy. When would you expect, Ooh, that’s a good question. When would you expect row compression to be better than page compression? So this is a, this is a good question. And, uh, fundamentally what it comes down to is data uniqueness.

Uh, so wrote, so the funny thing about page compression is that, uh, it will first try to apply row compression and then it will go through some other steps to try to further compress things at the page level, uh, using fancy things like dictionaries.

And, uh, I forget what the other thing is called, but, uh, what it’ll do is it will try to go and replace do like re like repetitive, uh, parts of data with expressions. So you can, you can, if you have very, very repetitive data, you can, you don’t have to store like say, you know, a million zeros.

You can just say, I have the value zero a million times. So row compression works really well for, um, you know, like dates, numbers, uh, to a certain extent, some, some strings, depending on, depending on a few things that I don’t want to get into, but, uh, row compression typically works well for more unique data.

Whereas page compression tends to get better, um, as you have more repetitive data. Uh, the other, the other crazy thing about page compression is that at some point it might give up trying to compress pages and just fall back solely to row compression.

Uh, so, you know, really, you know, take a good, hard look at your data, look at, um, you know, kind of how unique or not unique things are. Um, take a look at, I don’t know.

I don’t know. Sometimes testing it is just the best way to do it. Right. Uh, but let’s see my friend, my dear friend, another dear friend of mine, not quite as gifted at creating cutting boards, but very, very gifted at SQL Server things and making cocktails.

Andy Mallon. Uh, where is his GitHub? Where is Andy’s GitHub?

Does he have a link to it here? No, he doesn’t have a link to it here. Andy Mallon SQL Server GitHub. There we go. So Andy has a presentation.

Look at that handsome fella. I know drew is over there drooling if he’s still here, but Andy Mallon has a wonderful presentation on compression. Let’s see.

Where are you? Automation. Blazing performance. Ooh, I should read that. Shortcuts when to use. Where is the compression one? No.

Try to keep it family friendly. Ah, there we go. Demystifying data compression. There we go. There we go.

So there’s a link to that. Uh, Andy, uh, does a great job presenting about it. If you just look at the PowerPoint, you are doing yourself a disservice. You should definitely, definitely, uh, catch him do it.

Well, I mean, I don’t know. I don’t know if live and in person is going to be an option anytime soon. But Andy does speak at user groups pretty regularly. If you don’t already follow him on Twitter, uh, and there’s not enough dogs and food and cocktail making in your life, well, Andy’s a pretty good, pretty good choice to go and follow.

That’s why I follow. He’s my fashion icon. I just can’t afford those shirts.

Um, really, yes. Yes, Drew. Really good.

Really good. But yeah, so that’s a, that’s a good presentation on it. Um, you know, it’s a shame that, uh, the only place to get, uh, so this, uh, this guy, Lynchie Shea, uh, actually used to be part of the SQL Server user group. Um, uh, or rather, actually used to be the organizer of the, uh, SQL Server user group, uh, in New York City.

Used to blog over at SQL blog, which is like permanently offline now. So I’m gonna try to find the link. So I can put it into chat.

But I have, I have to, I have to go through. Oh, do I even have it anymore? So the only way to get to, uh, Lynchie’s stuff is on, um, the, the internet archive. I’ll have to go and dig that up.

Cause I don’t, I don’t think I have it bookmarked anymore. Yeah. I don’t. Darn it. Man.

Man. All right. I’ll have to go back and find that. So like the only way to get to, um, the only, only way to get, uh, to his stuff. He goes, he, he wrote about a lot of stuff. So Lynchie, uh, works for a big bank and, uh, Lynchie used to, um, run, have like, like at the time, very, very big servers and could run all sorts of crazy load tests with all sorts of crazy, all the crazy features that SQL Server was coming out with.

And just had access to like stuff and his company let him blogged about all these things. Um, so, and like, he just had like really cool stuff about, um, ways that compression helps, hurts, like, you know, when it’s good, when it’s bad. Uh, I’ll have to go through and dig that up somewhere.

Cause that, that’s, that was, those, those are still, uh, because compression hasn’t really changed since like 2008 or 10. So that stuff is all pretty reliable. So I would, I would definitely, I’ll, I’ll, I’ll, I’ll, I’ll, I’ll, I’ll dig up links to that through a web archive and, uh, I will post them along with the video content since I can’t find them quickly now.

And no one wants to sit here and watch me go through archive.org looking for stuff. Let’s see. Do I have some words to say about file stream?

I have terrible words to say about file stream. Don’t stop putting that stuff in your database. You can’t performance tune that stuff. Stuff is not, not good for you.

Um, don’t put your blobs in the databases, put stare, store links, store like paths to blobs, and then have the thing go find them on, on discs. And I know that, I know that makes some stuff difficult. Like you, like it’s, it’s like if you back up the database at a point in time, you don’t necessarily have the files backed up at a point in time, but man, gives me the, gives me both the heebies and the jeebies thinking about file stream in the database.

It is, you know, it’s again, it’s just developer squirrel stuff. It’s like, God, why, what are you doing to me? Like we have a query that’s going slow.

It’s touching file stream. I’m like, good luck. Good luck. Go. Show me. What’s the query plan for that? Just skulls.

It’s a bunch of skulls. Someone at our place did yuck. Surly dev, I understand why you’re surly now. I understand the surliness. I would be surly too, if I had to deal with file stream.

Yes. Just store a reference or path to file. That’s the way to do it. Oh, everyone should judge Microsoft. Microsoft is there to be judged.

When you’re paying $2,000 to $7,000 a core for a piece of software, you should, they are there to be judged. You’re not getting coupons from them. That is, that is the ultimate judge.

Like, people pay small sums of money to see my training and they give me feedback. And I am perfectly comfortable with being judged because they pay for a product and I want them to have the best possible thing. And, you know, I think the next round of training will be even better because I have an even better setup.

And, you know, I learned a lot of stuff from the first round of training, like, you know, recording it all nonstop over the course of a few days at the beginning of a pandemic. It’s probably not the ideal recording circumstances, but, you know, it’s okay. It’s okay.

Am I a Blackadder fan? No, I don’t, I don’t, I’m not, I’m not very big into a lot of the humor that gives people credibility in IT circles. I, you know, and you know what, it’s not because I watched it and didn’t like it.

It’s because I heard references or like people quoting this stuff so much that by the time I went and tried to watch it, I was like, oh, I know it’s going to happen. It’s like, oh yeah. Oh, yeah, look at that.

I know that joke. So it’s like, like, not that I didn’t like, not that I don’t like it. It’s just, I, the, the joke got ruined for me. Right. It’s like, it’s not bad.

It’s just, man. It’s like, I, I, like, like Doctor Who, Monty Python, Blackadder, Mr. Bean. Like, all of the, like, all like, like the, like the, like the nerdy, like, you know, like the nerdy fetish humor comedy stuff that like, you know, was very, I don’t know.

Like, like pointed commentary and sort of like a little bit transgressive. It’s just like, by the time you watch it, you’re like, oh yeah. Seen it.

Know what happened there. I don’t think it’s bad. It’s just, I wish that I, I wish that I hadn’t heard all the jokes ahead of time. Yes, I am showing all of Andy’s source code.

Mr. P. Shaw says, have you done anything with policy based management? Not, no. And no one else has either. It is, it is a pretty underused feature.

Like, I understand what it’s there for, but, so like, my story is, my story is with, with SQL Server is, I was mostly a developer for my career. I didn’t have to do a lot of DBA type stuff. And then, my, my big DBA job, which I didn’t have for a terribly long time, because Brent hired me, was at a relativity shop.

And if you don’t know what relativity is, it’s eDiscovery software. It is like the eDiscovery software. Like, if you’re not using relativity, you are probably doing something wrong.

But I was a DBA overseeing, I don’t know, like 100, 150 terabytes of data. I was the only DBA. It sucked.

But, yeah. And there wasn’t, there wasn’t a lot to do with policy based management there, or, or other things like that. And, you know, so like, I mean, most of what I did was, you know, making sure that the servers were alive, doing, doing like, you know, making sure like backups, like boring stuff, like stuff that DBAs just shouldn’t, like, like the reason why DB, like the boring stuff that DBAs are going away because of, where it’s just like, you know, like, like backups restores, setting up new servers, all that stuff. And that like, and like, I realized that that wasn’t really my love, like, like, like managing the high availability, all the sort of like infrastructure stuff, I realized that that wasn’t my love.

I loved, I love performance tuning stuff. So I would, you know, every chance I got, every chance I got, I would, you know, I would go back into index tuning, I would go back into looking at like the queries people were running and trying to tune those. It was like, that was always what I was drawn to, was never the infrastructure type stuff.

And so things like policy based management, well, I’m not like against them, I’m sure they have uses. I just haven’t seen a lot of people use them, like even from on the client side, like people who have DBAs who do love that stuff are like policy based what? A policy says what?

So yeah, I mean, no, I haven’t really done anything with it. I don’t really know anyone who does. I don’t, I don’t, like one way to really judge, I think the usefulness of a feature is to go and look at how many blog posts there are about it. If you’re just not seeing a lot of blog posts about it, then it’s really not, it’s probably really not catching on all that much.

Because when people get their hands on a feature that they either love or hate, you’ll see a lot of writing about how much they love or hate that feature and like, you know, various like good things or problems with it. But like policy based management isn’t something that I saw a ton on. So, I mean, not me, sorry.

So Lee Dev says in series four, there’s a character called Captain Darling. So this is a good example of things. Rob Farley, the most famous Australian in all of Australian history. He’s actually the first Australian to be born outside of a prison.

God bless Rob Farley. He yells Captain Darling or something about, yeah, how are you darling at me? In an Australian slash Englishy accent when he sees me.

And I miss seeing Rob Farley. I want to see Rob Farley live and in person again. So he can say that.

And then I can skip watching Blackadder because I’ve heard Rob Farley say that line to me. But you can say that to me too. I don’t think Rob would mind all that much.

Rob would probably be okay with it. Good old Rob. Good old Fob Farley. What a guy.

Let’s see here. Cool. So, yeah. So stuff going on with me. I don’t know. Maybe I’ll fill some dead air here rather than just thinking fondly of Rob Farley.

Next Friday. Next Friday. The 26th. I will be live streaming an online class. That’s going to be my advanced performance tuning material.

It’s going to be all the stuff that I was supposed to do for my SQL Saturday Chicago pre-con. It was supposed to be, I don’t know, three months ago now that obviously for reasons, got postponed and then canceled. So it’s canceled now.

There’s no thing in August anymore. But you can catch me live and in person doing it next Friday. It’s going to start at 10 a.m. Eastern. You can buy a seat for it. There’s a slide coming up.

Excuse you. That was a very big truck. There’s a slide coming up that has a link to it. And you get free access to all my videos, trainings, along with that purchase.

So if you want to come spend all day next Friday with me, you sure can do that. Coyote McD says, if you were hiring a junior DBA, what would you look for? Well, you know, junior is a funny word.

Um, because it’s sort of a loaded word, I think. So when you’re hiring a junior DBA, you’re not really, you’re not really hiring a DBA, right? You’re hiring someone who is curious, who is database curious.

Someone who is interested in databases. You can’t, like most of the time when you’re hiring a DBA, it’s a junior DBA rather. You’re hiring a junior DBA.

It’s, it’s, it’s like you just, you need someone who is smart and curious and responsible. And, you know, uh, let’s see some other, some other HR words, dependable, reliable, trainable, all that stuff. So, yeah, there’s, you know, there’s stuff that I would look for in the person.

There’s not necessarily something that I would look for in the qualification. Uh, you know, if, if, if they are like an intentional, Mr. P. Shaw has a good point. There are many, many accidental junior DBAs out there.

And, um, you know, by the time they’re getting hired, they’re not, they don’t, they don’t want to be junior anymore. They usually like kind of grow into that role. Um, yeah, yeah, there we go.

Meeting bingo. I love it. Proactive. That’s a good one too. That’s a good one. That’s a beautiful one. Uh, but yeah, so most of the time, you know, if I’m, if I’m looking for someone who I need to, or if I was looking for someone who I would need to fill junior DBA responsibilities, I don’t know what that I would ask them much about SQL Server. You know, I would probably ask them like, you know, uh, what, what they’re currently doing, what they like about databases, uh, you know, like what their current skillset is, how they think about it.

I think that might apply to databases. I’d ask them if they’re like, you know, if they, if they currently read, uh, you know, any of the, the vast, vast many SQL Server blogs out there, uh, things like that. You know, just like, you know, I would probably just want to get to know them as a, like, is this someone, like, is this someone I can work alongside and teach things to easily?

Is this someone who will go out and explore things and come to me with like questions? Not like, and not like, like spoon feeding questions, but like, you know, like good questions, like, Hey, I read about this and I got this far with it, but I’m kind of stuck here. What’s next?

Like, like, those are the questions. Like, those are the things that, uh, that I would want to like get to know, get to know about a person if I was going to hire them as a junior DBA. Um, no, I don’t see a ton of, of junior DBA job listings out there.

I don’t know. Maybe they exist. Maybe they don’t. I’m also, I’m also not, also not proactively looking for them. So there is my lack of proactivity.

Uh, but yeah, so, you know, uh, like I, it’s, it’s, it would, it would really be more about the person than about, um, than about if they had like any sort of SQL skills. Like, I don’t, I don’t care if they can, if I don’t care if they know what cross supply or filtered indexes or like what a B tree is or any of that stuff. I doesn’t like, do you, do you want to learn?

Cause I can teach you, you know, I can give you, I can give you that like sort of, uh, I don’t know. What’s the, um, the word for if you’re, if you, when you join a union, they call you a journeyman, but I’ll, I’ll say journey person. So if you, are you a good journey person to, to take on this role, to like learn about database?

Because it really is, it really is like that. You know, um, when you, when you get into the DBA world, uh, you, you have, you know, a few, there are a few different ways that you can, that you can hop in. Right.

There are a few different paths you can take. You know, if you want to just do pure development, if you want to do performance tuning, if you want to do sort of the infrastructure type stuff. And it, it takes a little time to figure out really what you’re into. Like I used to try, like, I used to think that like, it was important to be very, very good at both the infrastructure stuff and the performance tuning stuff.

But then like the more I worked with the infrastructure stuff, it was just kind of like, that’s not where I want to live. You know, that’s, um, those are the people who get called late, you know, weekend nights because the server is down. I don’t want that call.

I want the, we want this query to go faster call. Cause I can, I can sit there by myself and work on that. I can make it faster. Um, so like I used to try to, you know, think that like I had to fill, you know, all of the shoes. Uh, but I, I really just was drawn totally to the perf stuff.

And that’s going to happen with junior deep with people who you hire to be a junior DBA too. They’re going to start looking at stuff and they’re going to be like, I need everything. Like maybe I need to be an enterprise DBA and power show everything.

Or like, maybe I want to be really good at like this one thing or this other thing, availability groups or failover or whatever it is. And, you know, it’s going to take time for them to, uh, to learn, to settle on a path. And it’s going to kind of depend on what the job role entails too.

You know, if, if you’re hiring a junior DBA because you want someone to, you know, uh, hit play on a run book for when your AG goes down or something, then that’s, you know, that’s, that’s going to be what the path that they start on. But, you know, who knows if they’re going to stay on that forever. So, and then like, you know, even like once you choose between like whatever you want to do with databases, then you have to like, like dedicate to that and then, you know, get better at, at that.

It’s, and it’s, you know, anyone, anyone who tries to do two or more of those things is going to have a tough, tough time because there is just so much to keep up with. Um, things change so, so quickly, you know, even, even just like on the perf side, like keeping up with all the, all the new stuff and all the new changes and, you know, features and whatnot. It’s tough.

It’s, it’s difficult. Um, you know, you’re always going to have the, the evergreen, like sort of performance, duh stuff, right? Like you’re always going to, you’re always going to have to, at some point, teach people fundamentals, some point teach people, uh, what they need to grow into like a good full on DBA or whatever they want to call themselves.

But, you know, it’s there. Hiring, hiring juniors is, is hard though. So, I mean, I don’t know if we all kids these days, but I would imagine that it’s hard to find someone who wants to work on the database.

Everyone wants to learn to code, right? Everyone wants to learn whatever language is sexy on Hacker News this week or whatever they, whatever they found. Like everyone wants to learn Rust.

Everyone loves Rust. Go, whatever it is. Python. R. Snickers. I don’t know. It’s crazy.

Like, you know, people, people, people all want to, all want to learn the code. No one wants to learn the database. So I’d imagine it’d be tough to find, uh, a database person. You pretty much just have to like, you have to find a sysadmin and brainwash them.

You have to find a sysadmin and be like, you know, Windows is boring. Windows. SQL.

Okay. Look at this bright, shiny thing. Woo. Yeah. Want to be responsible for this? Yes. It’s expensive. Let’s see.

Someone with a very blue name. Um, gola boom. Go zero. I hope I, I hope I pronounced that right. If I got that wrong, you’ll have to give it to me phonetically in chat. But it says Python with a heart.

And, uh, yeah, you know, if I, if I had to go and learn a programming language, I would, I would probably go. Um, I would probably start with Python because I’m an idiot. And, uh, so far as I can tell, Python is a bit like coding with crayons.

And I think that’s where I would have to begin before I got into anything else. Botsco says, can you post those links in chat? I, you’re going to have to be more specific about which links you’re talking about because I don’t know.

I don’t know which links. You’re talking. I don’t know which links. I’m sorry. You’re going to have to tell me. About the event. Yeah, sure.

Actually, they’re right there. They’re going by. So let me pause the slideshow. So, oops. That didn’t do what I thought it would do. So if you go to that bit.ly link, there we go. All right.

You should be able to, let me, let me click on that and make sure that you get what you’re supposed to out of there. Yes, you do. You go right to event bright. And, uh, just like the wonderful slide says, if you, you buy a ticket over here, you will get access to all like thousand dollars worth of my video training.

For free. So it’s a flash sale. It’s crazy, right?

Crazy. And the, the, the, uh, I should, I should probably be very specific that the, uh, the online, the recorded training does include the material that we’ll be talking about during the, uh, during the performance tuning event.

So you will have a bit of a replay on that if, um, if you want to backtrack or if you have any questions. Um, so there’s, you have that to look forward to. If that’s, if that is the kind of thing that you look forward to, I don’t know if you do.

People have all sorts of strange kinks and fetishes and interests. I feel, I feel like unlike, unlike SQL Server job roles, it is, it is my, it is my job to fulfill as many of them as possible.

Uh, I have a, I’m, I’m ordering a firefighter, uh, outfit for the next, next, uh, live stream. So I’ll be hanging out in some cool hat and big suspenders. So if anyone has a firefighter thing.

No. All right. We’re silent on that. Silent. Oh, you’re not changing. You’re just sitting still. I hit the wrong button.

I think that should be the right button. This is rotating slide things. Interesting. Wait, no, you’re still not doing it.

Maybe that button is it. Who knows? I, I, like, don’t judge my, my SQL Server prowess by my PowerPoint prowess. Uh, SterlyDev says, I always have to remember that suspenders is American for braces.

Yes. Uh, do not try to put suspenders on your teeth. Um. Yeah.

And also don’t wear a belt and braces. You look foolish. In England you would be given, oh, I know.

Oh, I know. I know all about it. Yes. I’ve, I’ve listened to enough, I don’t know, uh, specials and madness and all those other scotch bands to know, to know darn well what my braces, my braces are.

Braces for your trousers and all that. Ha, ha, ha, ha, ha, ha. Uh, maybe out of context, but how well are your, my tattoos, my tattoos perceived as a consultant?

Uh, no, no one’s ever said anything. Uh, I think, I think some people, I think a few people have said that they, they look cool. But, no, no one said anything about it.

Uh, and if they did, I would be perfectly comfortable not working with someone who, who is like, ah, I can’t work with this tattooed fella. I would be like, I understand. I look like I’m on work release.

It doesn’t, it doesn’t, it wouldn’t bother me if someone said, ah, you look scuzzy. Why? Uh, do you have, do you have a lot of tattoos? Are you, are you heavily tattooed in some way?

Um, because I’m gonna, I’m gonna level with you. At some point, at some point in my life, I am going to get, uh, tattoos that are on my, my head area. I’m not gonna go hairline because I’m, I’m pretty sure that I’m gonna not, my, my forehead gets a little bit bigger every year.

So I’m not gonna go hairline. I’ll probably do like something like temple or maybe like corner of eye, but, um, but you know, uh, I, I, I would do that at some point. I just don’t care anymore.

I don’t know what I, I’m not gonna get like a middle finger or something, like something gross, but. We’ll get some dude ads up there. Get some dude ads.

Yeah, no one’s ever said anything. Uh, I think the only, and the only time I’ve ever, I’ve ever judged a client because of, of, of their lifestyle was, uh, I was on the phone with one guy and he was vaping the entire time. Excuse you, Mr. Truck.

He was vaping the entire time and not just like, like I have a vape pen vaping, like a, like a little, like dude ad. It was like this, like a shoe box, a shoe box full of liquid. And he would like take this, like, like this pull that just like went on.

It sounded, it sounded like I, like he was like, like unsticking something or like this huge pull. And then he would like do this, like dual exhale through his nose and mouth and you have this like, like beard and mustache smoke. And then like, it would just like cloud around him and he would disappear for a few seconds.

And then he would come back and be like, I am judging you. I am judging you with what you’re doing with that, that vape box. If it was just like a pen and he was just like, yeah, you know what?

No big deal. But it was just like this, like a dragon getting ready to like fry an army. It’s just like, all right. And like the worst part is that you watch that big cloud of smoke pop and you know, it’s just like, like cherry coconut fruit loop, double mango expression.

You’re like, come on, man. Like extra pineapples. I smell, I smell that on the street all the time.

I smell it. I know that you’re not, you’re not smoking anything that’s like, that smells like smoke. If you were just like smoking a cigarette, I would, I would judge someone less for smoking a cigarette than I would for a giant vape box of like 3X cherry nonsense.

Of course, my retirement plan is to live in France and Paris and in Montmartre and wear a lot of black Hermes and smoke Galois blonde blues until I, until I croak. That’s my retirement plan. That’s all I want to do.

Just wander around. Occasionally eating cheese. That’s my big retirement plan. I’ll never be able to do it, but that’s my plan.

That is what I’m going to do. But yeah, no one’s ever said anything about tattoos. And, you know, like I don’t, I don’t go out of my way to be like, look at my neck tattoo. Look at my hair.

Like I don’t, I’ve got out of my way about it, but it would be hard not to notice. And then what’s funny is like when I first started consulting, I was working for Brent. I think the first, like two or three calls that I was on where I was on camera. You know, like I had just gotten out of like, I don’t know, like 15 years of office jobs.

And so I was very used to just wearing like a button down. And so I would, I would wear, I would, I was wearing a button down for the first few meetings. And then I like, like I caught a glimpse of myself in the button down.

And like it had like, I would have like a small pattern on it. And like, I just had this like weird, like psychedelic effect on the camera. And I just was like, screw it.

And I, I stopped wearing them. If this, I used to have a lot of button down. They’re mostly just donated or something now. But yeah, so I used, I used to like try to, you know, be a little bit covered up, but. Let’s see.

What’s a button? That’s a button down shirt. It’s a shirt that has buttons down the front. You’re, you’re in England. So I don’t know. I guess you might recognize it as a, as a, as a Ben Sherman or a Brutus trim fit, maybe. Button downs.

There you go. Mon Mart is a bit expensive. Yes, it is. And that’s why I want to be there. That is where I want to live. Uber douche. If you don’t score a job because of your tattoos, you’re probably dodging.

Yes, absolutely. Absolutely. If I, if, if, if there is, you know, they don’t, they don’t call them job stoppers for nothing. And so if there’s a, if there’s someone who’s just like, ah, I see him. I don’t like him.

I only had one person ever say that to me in an interview too. And it was funny because he was, he was very specific about it. He was like, you know, the neck tattoos, not a big deal. The hand tattoos.

I think, I think people wouldn’t like them. And I’m like, they’re not, not like offensive. It’s not like I have like, like, like, you know, I wish I had Beavis and Butthead on my hand. Now that I think about it, I’m going to go get these removed. Go get Beavis and Butthead tattoos on my hands.

But, um, like, it’s not like I have anything offensive. But, uh, he was just like, yeah, you know, the hand tattoos, people would really not like those. The neck tattoo is not a big deal. And I was just like, okay, no problem.

Hmm, I understand. I get it. Yeah, so a shirt or a dress shirt. Button down, button down shirt. Uh, button down pants would be a little bit silly. Maybe.

Kind of depends on, kind of depends on how, how many bathroom emergencies you have. Die Bart, die in your fingers. Yes. Do I have enough fingers for that?

E-I-E-B-A-R-T-D. Oh, I ran out of fingers. Yeah. And I can get that somewhere. I would, I would actually happily get that somewhere.

Happily get that somewhere. I have all sorts, I have all sorts of like, I guess the nice thing about, uh, having all this time inside to think is, you start thinking, my knuckles are full.

I got no more room on my knuckles. They’re covered. Uh, the, the nice thing about endorsing is that I have lots of time to think about all the things I’m going to do when I get to go back outside.

And I’m excited because New York is, uh, in, in phase one now. And we will be finding out today if we begin phase two on Monday. Uh, Governor Cuomo and, and Mayor Blah, uh, apparently some disagreement on it.

I’m going to have to check the news when we’re done here. Our mayor said that we’re going for phase two on Monday. And Cuomo said, uh, I’ll tell you on Friday if you are.

So, um, got smacked a little bit on that again, again. Like the, like the crazy thing about the last three months, like, like, like I’m, I’m not a terribly political person.

I, I find politics, uh, quite dull and boring. Um, you know, I spent a lot of my youth going to, uh, punk shows and meeting a lot of very political people.

And the one thing that struck me about all of them was that they were very fundamentally unhappy. They were just always miserable. And so, um, I just, as a kid, I got like this weird, like, like, uh, like, uh, clockwork orange response to anything political.

But like the craziest thing about, um, uh, all of the, the, um, the, the pandemic stuff is just watching like, like the mayor of New York city and the governor of New York, like just clash constantly.

And the governor is just like, no, I, I, I have the bigger hammer. And the man is just like, uh, let’s see. I know a guy that tattooed an execution plan on his forearm, a pretty well-known SQL MVP.

Wow. Uh, that is certainly commitment. I don’t think I’ve ever had an execution plan. Um, well, clearly I live in the part of New York that has festive outdoor music.

Um, but like, I’ve never, I don’t think I’ve ever seen an execution plan that I would want tattooed on me. Anytime an execution plan has struck me in such a way, uh, it has been because I found it deeply, terribly offensive.

Uh, many of them have been parallel merge joins. It’s usually a good sign. Um, but yeah, uh, I am in Brooklyn, New York, David P. That’s about as specific, that’s about as specific as I’ll get.

Jeez. I can’t imagine getting an execution plan tattooed on me. Not even as like a cheat sheet.

Uh, let’s see here. Uh, did you try out the graph database in SQL Server? Do you advise it?

Do you think Microsoft, uh, will it follow this path? I don’t know. Um, you know, Microsoft is just so famous, uh, especially in SQL Server for giving you V1 of a feature and then, you know, just kind of abandoning it.

Like not, not a lot, there’s not a lot of movement on it. Um, you know, um, I think, uh, the spatial data is a pretty good example of that. Uh, there’s a lot of stuff that like even Postgres just wipes the floor with, uh, with SQL Server on like, oh, like the geography stuff.

Like they just have so much better support for it. Um, so like Microsoft just gives you such like V, like, like everything still has that V1 smell. And, uh, it just never really progresses on past that.

So, yeah, I don’t know. I don’t know. So I, no, I haven’t messed with it. I haven’t messed with graph because graph is not my thing. It is not anything that, uh, that particularly calls to me.

Um, I don’t think it’s bad by any stretch. Um, I haven’t seen anyone, uh, really use it to do anything all that cool or interesting yet.

Uh, maybe someone much smarter than me will, um, or someone who, you know, spends time with it. We’ll figure out some things. Um, you know, it’s, it’s something where like, uh, if you start using graph and graph does not catch on and, uh, you run into any unfortunate limitations or, uh, you know, bugs are issues.

You might have a tough time getting Microsoft to take care of stuff because you might be a very, very lonely voice in the wilderness asking for these things. And when something is not, uh, an immediate priority or concern, it’s very difficult internally to get developer cycles, uh, dedicated to fixing or improving things.

If you found like a big security flaw with it or something, that might be a different story. But if you’re just like, you know, I really wish it did this, but it doesn’t do this.

You might just get someone to be like, oh, you know, that will be really hard to implement. Like they’ll BS you all day about, uh, it’ll be really hard. I don’t know if we can do that, which is really just code for, yeah, I don’t know if I can get, I like, like no one wants to put time or effort into this thing.

No one’s using it. You know, um, we look at the, we look at the customer experience improvement data and we don’t see anyone using this feature. So we’re just not going to concentrate on it.

And I feel bad for people who, who, you know, uh, wait and wait for these features, wait and wait for these things to get implemented in SQL Server. And then they come out and they’re like, well, you know, it’s our initial thing.

We’ll, you know, get work on it more later. And like, you just have like a handful of people who use it. And then Microsoft is like, that’s good enough. Let’s leave it there.

Like, you know, there’s so many things that like came out and like not like nothing improved about them. And then, you know, you, you stand the risk of Microsoft saying, well, we’re going to do this different thing and you’ll have to use this different thing.

If you want this other stuff, it’s like, take it, like take, take availability groups, right? You had mirroring, you had mirroring for years, right? Like Microsoft could have just made mirroring better, but no, they went and made availability groups and they deprecated mirroring.

So now everyone using mirroring is like, crap, we got to use availability groups. Like Amazon RDS behind the scenes, some years used mirroring. I’m pretty sure they’re going to have to switch to availability groups at some point. So it’s like, you know, like, like all this stuff that like people get, you know, uh, very invested in and then they get nothing else out of it.

It’s sad. Like, I think, you know, stuff like, uh, you know, big data clusters and, uh, some of the other new stuff that people are just like, push, push, push, push, push on. You know, if, if no one, no one uses it, if no one’s out there seriously using it, you’re just not going to see like the improving, like not going to see like the, the dedication to making something better.

And like, I totally understand why people don’t use things at V1. And I totally understand why people don’t use new versions of SQL Server until a certain number of cumulative updates of, or well, now nowadays cumulative updates have passed.

I get it. Like I totally understand. I totally understand. Unfortunately, V1 smell is not nearly as good as new car smell. You are right about that.

Um, I also like the smell of freshly cut wood. And, uh, I, I, I, I enjoy that smell. Drew has sent me three dogs.

Is that, is that, are you, is that what you would rate this live stream? This is a three dog live stream. I don’t know.

You’re going to have to explain that one. That’s a very cute dog though. Is that, is that a dog meme? I don’t know.

I’d make a, I’d make a CrossFit joke, but no one does CrossFit anymore. Everyone does something else. I don’t know if it has a name, but I’m, I’ve been assured it’s not, it’s no longer CrossFit.

They’re doing, uh, exercises of the day. Group of exercises for today, which is totally different. Wow.

A hundred messages. Ooh, we think only a few of them are mine. I feel like that’s a real, it’s a good benchmark. It’s a good benchmark. How long have I been recording? Is it an hour? Where is, there it is. Wow.

Eh, not quite. Go a little bit longer. Make sure, make sure I have a solid 60 for you. Not like Drew’s sad half mast for Randy. Give you a solid 60% mast.

60 minute mast. 60. I don’t know. Maybe.

Or an operator. Or an operator. Or an operator. What operator would it be? Well, it’s funny because I don’t think it would be a single operator. I think it would be, uh, I think it would have to be, uh, a combination of operators. I think it would have to be, uh, like clustered index scans and a hash join.

I think it would have to be that. I don’t know. I don’t know.

Maybe it would be a hash aggregate. And then squats could be a hash join. Yeah, because I guess if you’re, if you’re squatting, you’re, you got your legs out a little bit further. Right?

Right now. And you go, right? Like my hands aren’t in the right place. Don’t judge me. I have a green screen behind me. So I can’t really, and it’s also tough to get into position without A, having a bar and B, without having gotten to do a squat in almost four months. Uh, so my hands aren’t in the right place.

So don’t, don’t think that I do high bar squats like some Olympic lame-o. Uh, I’m kidding. Olympians aren’t lame-os, but high bar squatting is dumb. Um, so I guess a squat, your legs are further apart.

So that your feet separation kind of looks like, you know, what you would see from a join. And then with a deadlift, your feet, unless you squat sumo like a cheater, your feet are closer.

So that would be more like a hash aggregate. So I think squats are like a hash join. Deadlifts are like a, like a hash aggregate. Um, and I guess, and that’s that. I don’t know.

I don’t know. I think overhead press would be a stream aggregate because you really have to make sure that you are streamed in line. Get that thing up.

Bench press. I don’t know. I have to think about bench press. Don’t want to call bench press a nested loop join.

Even though maybe, maybe bench press could be a lazy spool because you’re laying down while you do it. Sounds right to me.

Bench press is an act of laziness. Laying there. Counting on the bench to do all that work. Pshaw.

Then what else? What else? What else? I don’t know. I don’t know.

I think, uh, I think that all this talk just makes me miss going to the gym even more. Like I didn’t, I didn’t realize until I couldn’t go for, uh, for months on end for a reason that was not injury related.

I’ve had, I’ve definitely had injuries that have kept me out of the gym for a bit, but I’ve never just like been in, in perfectly good health and, and not been able to go to the gym and I didn’t realize, um, how much of a nice, uh, mental break it was from, from work stuff and how much of an, like how much of a, of an outlet it was to like go and just like blow off steam and think about something else and concentrate on something else.

I didn’t like, cause I knew, but I didn’t like, like I knew I like that I felt good for, for having gone and done things, but I did not realize, um, just how, just how much of an effect it had on my life.

And, uh, I have not been able to, to replicate that with any of the, the, the things that I’ve been doing at home. And, uh, I just have no interest in like going for a job. It’s not my jam.

So, you know, it’s, it’s tough to, it’s, it’s, it really, it really is difficult to find a, a replacement for that. Cause I really just don’t think there is one. Like I realized it’s not everyone’s thing.

Not everyone cares about it. You know, other people might have other things they want to go do. They want to go do gymnastics or suspension or TRX or, you know, yoga or whatever it is. But you know, it’s everyone has their thing.

That’s my thing. It was apparently a big thing. And once it was gone, I was just like, huh, huh, looking around uncomfortably, like, what can I do?

What can I do? I don’t know. Anyway, anyway, uh, the flow of questions seems to have slowed down a little bit. So, uh, I’m going to call this one here.

Uh, thank you all for, uh, for joining me today. It was a pleasure. Uh, since, you know, uh, this, this seemed to go pretty well. There was some pretty good, uh, pretty good stuff in here.

I, I’ll, I’ll probably go back to doing this once a week. I don’t know if it’s going to be every Friday, but I’ll, I’ll, I’ll do a, I’ll do one or two of these a week probably as long as I, as long as it fits the schedule, if it fits your macros, uh, I’ll do it.

I’ll do a one or two of these a week. And, um, yeah, if you, if you find yourself, uh, out in the world, uh, watching this video and you, you enjoy it or you enjoy any of the other videos you see on my various channels, uh, you know, throw, throw, throw me a subscribe so that you can find your way back for, uh, for more content, like more SQL Server content.

And, you know, maybe, maybe I’ll do exercise. Maybe I’ll just do film myself doing some jazzercise, some step-ups, right? Getting a nice butt.

But, uh, yeah, uh, I’ll come back. Love to have you. Love, love questions. Love, love seeing eyeballs down at the bottom. So come on back, join me again. And, uh, I don’t know.

Thanks for, thanks for watching and all that. All right. Catch you next time.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I delve into the exciting world of performance tuning and database management, sharing insights from recent experiences and upcoming changes. I discuss how new features like Windows Server 2019’s Perfmon, which redesigns the user interface to look more modern and interactive, are poised to revolutionize monitoring tools for SQL Server administrators. Additionally, I reflect on my recent speaking engagements at SQL Saturday Portland and the anticipation of returning to SQL Bits in February, where I’ll be presenting new material relevant to the latest database technologies and challenges.

Full Transcript

I apologize for being mildly late. I was trying to figure out how to get the thumbnail set up exactly how I wanted it. I have this strained mirror. I have fun with the mirror. It’s a telescoping thing. I can point it at all sorts of stuff. I have fun. Enjoying myself. The only thing I’m terrified of is that someone might see what’s on the wall behind my monitor. It’s largely pornographic posters. I have fun with the mirror. I have fun with the mirror. I have fun with the mirror. Just kidding. Just kidding. Just kidding. What do I do with that mirror? I don’t know. Nothing. You can hear me, right? This isn’t like one of those things where I’m talking and no one can hear me and everyone’s having a bad time. That’s going to happen. That’s going to kill myself.

That’s going to kill myself today. That’s going to be the end of it. The end of it. Sound is good. Wonderful. Wonderful. So who has questions? Someone better have questions. Maybe doing this during pass was a bad idea. I assume people who show up here are there. I would expect low attendance. All right. Someone.

I’m going to count to 100. I’m going to count to 100 in my head. If we don’t have any questions, I’m going to get a haircut. Because this is a bit much. Bum, bum, bum, bum, bum, bum, bum, bum, bum, bum, bum, bum.

All right. All right. Well. There are no questions.

There are no questions. There are no questions. Oh, there is a question.

How lucky. Varus says, I’m talking with people who want to use GUIDs instead of identity columns because they’re afraid of outages from either running out or having big int conversion errors. Why not just use a big int?

Here’s your identity column. There’s very little downside to that. It would take you until, I don’t know, like the heat, death, and rebirth of the universe to really run out of those. And if the argument has ever been that big ints are 8 bytes and ints are 4 bytes, well, GUIDs are, what, like 30-something?

I mean, what’s the point there? And then you have to do all sorts of weird juggling with your indexes. All right.

Because unless you’re generating sequential GUIDs, then we don’t want a clustered index on that GUID column. Even if it is sequential, if you restart, you might have some weird artifacts when the server comes back up. But if you’re generating random GUIDs, then it can be especially difficult on a clustered index.

So I would probably just say, how about this lovely big int? Big ints are wonderful. All ints should be big ints.

There should be no medium int. Big ints are nothing. Bites be damned. These sort of design questions are funny because people think GUIDs are magical.

And I guess for uniqueness, they are. But they make so many other things. Quite obnoxious.

Non-clustered primary keys on GUIDs. Clustered indexes on other columns, which usually end up being integers anyway. I don’t know.

It’s all weird to think about. Like, I wonder what keeps someone up at night thinking about these things to the point where they have to fall into the GUID trap. SQL Server 2019 is out, huh?

How about a hand for SQL Server 2019 where all of my demos except a few still work? Problem not solved, I guess, is the bottom line there. I don’t know.

It’s cool, though. It’ll be fun seeing how getting batch mode on the reg changes stuff for people. So, Farah says, and what if you’re trying to convince someone who’s afraid of running out of big ints?

How do you communicate this with very non-technical people? I mean, I guess I would say… So, like, the usual thing to do would be to…

What do you call it? What’s that word? Estimate.

I knew it was in there somewhere. Estimate the transactional activity of this application that you’re building. Say, how many applications do you… Or how many…

How many transactions do you expect a day in this application? And then divide that out and, like, see if you can figure out how long it would take. How many days it would take to run out of big ints.

And then, like, okay, if you were wrong by a factor of two, if we have twice as many, if we have four times as many, this is how long big ints will still last for. And I’m willing to bet, I’m willing to throw this out there, that perhaps by the time you approach running out of those big ints, we might have an even bigger int available.

Or we might be quantum computing where integers have no meaning or something. That’s a thing, right? Lee asks, from a fan of window functions.

Yes, from time to time, when they’re necessary. Performance of window functions usually comes down to having an adequate index on your partition by and order by elements. Usually.

At least for me, anyway. Some people can get away. Some people who do demos on AdventureWorks can get away with whatever indexes they want. Other people who have real databases or, you know, databases that are bigger than, like, 20 megs or something, they have different problems.

Yeah. Using that index, they’re wonderful. Otherwise, you better hope that… So if you really want to play with something cool, I don’t know what version of SQL Server you’re on, but if you really want to play with something cool with windowing functions, see what happens when you involve a columnstore index and you get a window aggregate.

Those are super fun to get. If you think windowing functions with the partition over by covering index is fast, wait until you get a window aggregate.

2017. So yeah, what I would do, if you’re on 2017, create a temp table with a clustered columnstore index on it, and then left join to that temp table on 1 equals 0, and you may see a window aggregate function show up, and when you do, you’ll wonder how you ever lived without them.

I think the thing to be careful with with window functions is that by default… Is this a trick to enable set-based operators? It’s an interesting question.

Batch mode operators is what it enables. Batch mode operators. But the thing to be really careful with with windowing functions is that by default, they will work on the range of rows rather than a set number of rows.

You have to set… You have to tell that windowing function to work on rows unbounded proceeding, yada, yada, versus range unbounded yada, yada, proceeding, because the range, when you work with ranges, you can get this crappy on-disc spool of data.

It can be very slow. Whereas with using the rows specification, you can… You get the in-memory spool or something like that.

So that’s another thing to be careful of with the old windowing functions. Watch out for that. It’s a big deal sometimes. Also, they act differently.

Ranges and rows. Much different. It’s always fun to revisit this stuff, because I don’t think about it terribly often.

Because it’s stuff that I’ve… It’s been settled in my head. For so long that I don’t think about it too much. It’s like what I’m going to order at a bar, because I just don’t go to bars that much anymore.

It doesn’t matter. What do you want? The drink. The drink you make. Yeah, look up the syntax for windowing functions. Make sure you understand the full difference.

I actually… Blah, blah, blah, blah, blah. Let’s see here. Window functions.

I bet that post is still up, because Brent seems to like my SEO. So I’ll stick that link in chat.

Forrest asks if I’ve seen much of a difference in performance due to underlying OS, e.g. server 2012 versus 2016. God, you know…

This is going to sound obtuse of me, but when I was a DBA, everything was mostly server 2008.

And then as a consultant, most servers seem to go from 2008 to 2016. I didn’t see a whole lot of people on server 2012.

So I’m not sure that I would be able to give you like a specific performance difference between the two. I’m sure there’s stuff.

I’m sure there’s improvements to Windows in the way that like CPU and memory and IO and everything is handled by the operating system. I’m sure that comes into things.

But gosh, I don’t think I’ve ever… I don’t think I’ve ever looked at someone’s performance problem and been like, ah, shucks. If only you were on server 2016, 19 or something.

That reminds me. I have to start downloading Windows Server 2019. You know what I’m really excited about? The new Perfmon. New Perfmon looks like a cool video game. It’s all like 3D and bejazzled and stuff.

It’s fantastic looking. I can’t wait. I can’t wait for that new Perfmon. Let’s see if I can find a link.

New Perfmon. Yeah, buddy. Yeah, buddy. Stick that link in chat. In case anyone’s interested in looking at the new Perfmon.

It looks so cool. It’s all like Power BI. There are like charts and graphs and stuff. I think you can search for like which object you want instead of having to like just like scroll through that absurd list.

It looks so good. I can’t wait for the new Perfmon. I might start using Perfmon. I’m so bad at using Perfmon.

Like when people are like, I have a problem with blah, blah, blah. I’m like, we’re not using Perfmon. Because A, I’m not good at it. B, I get really annoyed at how all the measurements can be like different scales. Like one being at 100 can mean one thing.

Another one being at 100 can mean another thing. And then none of it makes sense. I get annoyed at trying to figure out which collectors I need. I’ve just been really, really bad at Perfmon.

So I quit Perfmon. Until I saw that Perfmon. That new Perfmon. And now I’m excited about Perfmon again. I’m very excited about Perfmon.

I can’t wait for new Perfmon. It’s exciting times for Perfmon. Very excited.

It’s going to be a good time. Better or worse than PSS-Diag. You know, I’ve only ever run PSS-Diag when it’s been asked of me.

I’ve never, like, experimented with it as an application, like, on my own. And it seems like it’s, like, for some reason it just feels like it’s too late in the game for me to do that. Like, I’m not going to spin up PSS-Diag today and be like, ooh, look what I can do.

I feel like, you know. Like, those blog posts would have been great in 2008. Right?

Or, like, something like that. Now, if I’m like, look at this cool thing I can do with PSS-Diag. Someone’s like, yeah, but, you know, I have a monitoring tool. And it looks bad.

It’s just, it looks ugly. And I don’t know. Like, spits out a text file or something. And start, like, using, like, SQL Pal or SQL Nexus or whatever those things were that weren’t, like, the old troubleshooting tools.

Stuff that people use then. I don’t know. My dear, or rather, our dear friend Sean Gilardi seems to enjoy PSS-Diag.

So, maybe there is something. Maybe if someone starts blogging about PSS-Diag today, like, how do you use PSS-Diag? Damn it.

Maybe he’ll give it a shot. Maybe he’ll see what happens. I’ve heard various rumors that other consulting companies are big fans of using PSS-Diag as a data collector. So, I don’t know.

Maybe there’s hope for it. Maybe there’s hope for me. Maybe I’ll become the king of PSS-Diag, the prince of PSS-Diag. I don’t know.

We’ll see what happens. But I’m really excited about Perfmon. I think I might start using Perfmon, like, casually. The way it looks now.

Whoever redesigned that was a genius. A genius! Pure genius. I was out in Portland last Friday. Doing a pre-con for SQL Saturday Portland.

That was a lot of fun. I forget how many people were there. Good chunk of people. Good chunk.

Good chunk of happy learning people. I had someone join late, too. So, there was, like, one person who couldn’t get a seat in the room. They had to, like, use two chairs as a desk. So, I appreciate their tenacity in the matter.

Yeah. It’s a good time. Yeah. Total server performance. I like that material a lot.

I generally like the flow of the day. I like teaching people about when hardware sucks. And how queries look when hardware sucks. And then kind of getting into how queries can still be bad, even when hardware is good.

You know? I think it’s a good set of lessons for the day. I am working on… Yeah, you were there at SQL Bits.

Which I… Even more exciting. Holy cow. Simon tweeted earlier today that he has a contract for SQL Bits on his desk. I thought it wasn’t going to happen.

I was, like, nervous. Because February… Like, usually I know if I’m going to be at SQL Bits in, like, August. And this year there was nothing. I, like, emailed them. I was like, what’s going on?

I didn’t hear anything. And I was just like, man, is this not happening this year? Like, am I going to have the saddest year of my life in which I don’t go to SQL Bits? And then there was a tweet today about he has a contract for it. So, can’t wait.

Can’t wait. I would even be happy if it was in Manchester again. Like, if SQL Bits is in Manchester, I will be there. I will go to the Britain’s Protection. I will hang out.

That was a good bar. That was a fun place to get drunk. With Penal. So, yeah, I would happily do that. You know, it’s a fun session.

You know? I’m working on new stuff, of course. You know, I got to keep the material rolling. I got to keep it fresh. Especially with 2019 out, I got to make sure that I’m teaching people about not just, you know, stuff that can go wrong today, but stuff that still isn’t fixed in the future. You know?

It’s a… People keep saying that, like, you know, performance tuning is dead. I’m not going to need performance tutors anymore. I’m like, yeah, okay. Okay. I believe you.

I believe you. Me and the… Let’s see. I don’t know. I don’t have a count right now, but I would bet that I have had about 60 clients this year. And that’s not bad for a fella just starting out in his first year of consulting all by himself.

I would bet that performance tuning is not quite dead. Thoughts on accelerated database recovery. So accelerated database recovery is a feature that makes rollbacks very fast.

Rollbacks used to be very, very slow, single-threaded duty head operations. Now they are very fast. They are nearly instant because of something in the database called the persistent version store, which I hope will be used to get rid of spools and execution plans.

But that’s besides the point. But yeah, it looks cool so far. It looks like a fun time.

It’ll be interesting to see what that does to a few different things, like database sizes. It’ll be fun to see what it does to… What do you call it?

Like, when I played with it, cleanup was, for some reason, really slow. It took, like, 17 minutes to clean up 7 gigs or something like that. I was unhappy with that. Lee says, oh, boy.

Lee, yes. Have you ever had query store refuse to force a query? No error, and it says it’s forced, but it won’t use it. Yes.

Yes, I have. In fact, in my blog post today, I talked about how a query that I wrote with a hint and said, SQL Server use this version of the execution plan for all of these queries, and it refused to do it. Outright refused.

I would use a query, like a use plan, like if I set up a plan guide for it, it would use that. But it would not… Query store refused to do it.

I was very upset about that. Kendra Little… Actually, the link might be in the post today. But Kendra Little has a blog post about morally equivalent plans, which I find fascinating because… It isn’t in there.

Okay. So I’ll… Little… Little… Morally… And…

Uh… Uh… Uh… There we go.

There we go. Yes. Kendra is fantastic. So there’s a good link in there. Um…

Yeah, it’s… Uh… So I had… I had query store refuse to… So the problem that I was facing was I had an entity framework query that had, like, a whole bunch of left joins inside, like, a derived join. And then that derived join joined back to, like, a base table.

And it was, like… It was pretty… Pretty crazy what was going on inside there. And, um… The query had a 70 second compile time.

7-0. 70… 7-0 second compile time, meaning that query… It took that query a minute and 10 seconds to get an execution plan. And…

Uh… When it was done, it finished in, like, 600 milliseconds. And the… Since it was entity framework, there wasn’t, like, a lot of rewrites we could do. But I could use a, uh…

I could use a force order hint on the query. And that would get it to finish instantly. Because rather than spend a whole lot of time trying to rewrite join orders, we could…

Or I could tell the optimizer to just join the tables in the order that the query is written. And when I did that, it finished instantly. And when I tried to force that plan in Query Store, Query Store did not honor that plan.

It didn’t say it failed. It didn’t say, no, thank you. It just said, cool. I appreciate the advice. And it just kept on doing what it was doing. Taking 70 seconds to compile this plan.

So… Made a plan guide. Plan guide worked. Query finished instantly. Every single time after that. Happily ever after.

Oh. Suppose that’s why they paid me several of the bucks. Get query…

I get query optimization. I optimize query optimization. From 70 seconds to 0 seconds. It’s amazing. It’s amazing.

Right? That was probably one of the more fun problems that I’ve run into recently, too. You know, is… When you’re a consultant and you work with enough people, you kind of see… I would say, like, if you took a bingo card, you could probably win it once per client if you put, like, the most common issues on there.

It’s very, very rare that someone has, like, a new, exciting, dangerous problem. No, it’s… No, it’s…

I would imagine… So, like, query store is one of those funny things where, A, you have to have enough people on 2016 who, B, turn it on, and C, look at it, and then D, try to solve a problem with it, and E, have that problem be forcing a query plan to really get adequate feedback on if it’s going to be a new problem. And, like, the future is working well or not.

And… And… Not enough people get all the way to E. So, I think there’s probably some bugs and some issues in there that Microsoft has yet to, you know, fully flesh out just because not enough people are using it. It would be like, for example…

An example that’s very close to home for me. An example of the writing of SPBlitz Query Store. Query Store enabled where they would run…

They would run those things. Look at it. Boy. You know, there might be a million bugs in there that I don’t know about because not enough other people have looked at stuff. I mean, I’m mostly annoyed that the way the Query Store tables are designed, it makes it impossible to get reliably fast queries from them.

But that’s another matter. How much consulting do you do for Azure SQL DBs? Not a lot.

Not a lot. Done some. Done a few. Even… I even consulted for someone using Azure… What do you call them? Elastic pools where they scale up as query traffic gets more intense.

And they were using a whole lot of columnstore and still having some issues. But, yeah, not a lot. I don’t hear a lot from those people.

Which is, you know… You know, I won’t say that’s fine with me because I don’t want to, like, you know… Act like I don’t want to consult for people who are using Azure SQL DB. But it is rather more difficult to, you know, run some basic checks and queries against Azure SQL DB.

Because of how it might change and because cross-database queries and everything are awkward. And, you know, there’s a lot of stuff that’s different. There’s a lot of stuff that, like, you can’t do or change with Azure SQL DB that would make my recommendations useless.

So, I don’t know. I’m happy if people are happy. Managed instances, though.

I can’t wait until I start getting some people on those. Because those are cool, fun, exciting, sexy new… I don’t know.

It’s like new lingerie for servers. I’m excited about those. Very excited about those. I can’t wait to hear what Microsoft ends up rebranding managed instances as. Azure SQL data warehouse is now Synapse or something.

Sounds vaguely like a gaming keyboard. So, I’m not excited about that. Whatever.

Anyway, we’re about at the half hour mark. You lovely few have kept me company for long enough. You can stop desperately trying to think of questions to ask. I should be here next week.

Maybe, probably, hopefully. We’ll see. Thanks for showing up. And I will see you next time. Goodbye. Goodbye.

Goodbye. Goodbye. Goodbye. Goodbye. Goodbye. Goodbye. Bye.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I share a bizarre personal experience that has been affecting my daily life for the past few weeks. After taking an unexpected dose of antihistamines, I’ve found myself dealing with a range of side effects, including exhaustion and a general sense of being more tired than usual. Despite these challenges, I dive into various SQL Server topics, discussing the latest updates from Ola Hallengren’s scripts, the potential benefits and pitfalls of ADR (Accelerated Database Recovery), and advice for teams transitioning between SQL Server editions. The conversation also touches on my experiences working with maintenance plans and how they have remained largely unchanged over the years, prompting me to reflect on the evolution—or lack thereof—of certain features in SQL Server.

Full Transcript

I’m live. How lucky for me. How very, very lucky for me. It was recently brought to my attention that some people really enjoy my non-SQL related babbling that goes on until I’m not going to be able to do it. enough people show up and start talking. Hello, friend Peter. So, I’m going to waste a little bit of time while people show up and get questions ready by talking about something really crazy that happened to me. I talked a little bit about it. I can’t remember too well. It’s been a weird month. And the reason it’s been a weird month is because about a month ago, I woke up in the middle of the night and the world was spinning in a way that I have never experienced the world spinning before. At first I thought it was just booze. Like I sat up and I felt better. And then I was like, all right, lay back down. I lay back down and I was okay unless I turned my head from one side to the other. And when I turned my head to the side, the world would just go spinning like crazy. And I turned this side, it would do the same thing. And, uh, it turns out that I had vertigo or benign peroxial. I forget what the P and the V stand for, but I had that. And so I did this thing called the Epley maneuver where you like lay with your head back and tilt from side to side and do this stuff until the dizziness stops. And that’s supposed to like realign this stuff in your head that’s causing the vertigo. And that worked. That worked. When I lay down, I could move my head from side to side and I no longer have crazy crazy world spinning stuff. Uh, but what did happen after that is. This sort of like background discomfort, what felt like motion sickness. And the reason I know what this felt like is cause when, when Brent took us on, uh, the cruise to Alaska, I got, there was a rough night at sea when I got really, really bad sea sickness. I wasn’t throwing up, but like it threw me off and I had to take antihistamines for like, a month after we got home. So it was like this very same feeling. I think like, I, I don’t forget what I took last time, but this time around I took a different antihistamine.

And, uh, the, like a funny side effect of like consistent antihistamine use that I recently learned is that it makes your eyes very dry. Like my eyes just felt deplete. Like I just felt like I had sand in my eyes constantly. And like an idiot, I thought it was just allergies. And so I was using allergy eye drops in my eyes on top of take. So I was probably just making, making matters worse. Uh, and, and now, now I’m taking this, like, like this, like dry eye specific eye drops. And, and my eyes finally feel like a little bit less crappy, but it was like, they were dry to the point where like, when I blinked, my eyelids would twitch. And I was like, so like when you put together, so no, the other thing about it so dry that like, like bright lights were a little blurry. So like you put dizziness, blurry, bright lights. And, uh, and what was the other thing? And the, whatever else I said, and you put those together. I’m like, man, I’m dead.

But then I start re like reading and I’m like, Oh no, I might just have very dry eyes from antihistamines, everything else. So I’ve come full circle. Basically this is, this is the index fragmentation of the human body is, uh, I kept doing, I kept, I kept fighting symptom after symptom. Um, when really I just had to stop, if I stopped fighting symptoms and things would have gotten better.

Oh, I can’t believe I told, I told you all that just to get there. Ah, something else. Well, the, the million of you that are in here, the billions of you that are in here, someone has to have a question about SQL Server.

When do you better have a question about SQL Server or you’re all in trouble? Really? Poop pains.

No, no. Thankfully, no poop pains. Thankfully, blessedly poop pain free. Can’t complain about that. No. Other stuff. You know, other stuff gets weird.

I just have, I’ve, what it all comes down to is I have terrible sinuses and inner ears. I said that I’ve been like that my entire life. And so like anything that goes a little bit wrong with an ear or a sinus turns into like a month long fight. Like my head feels like there’s someone inflating bike tires in it.

And I get all woogie and wonky and I stare at things funny. It’s no fun. I wish, I wish that there were just surgery where I could get my sinuses removed and replaced with like stainless steel. That would be nice.

George wants to know if in-memory OLTP is any good. Any good? Sure. For limited values of any. If you need to, if you need to plop data into tables very quickly, it’s very good.

If you need to modify data in those tables pretty quickly and match free, it can be pretty good for that. But, you know, I would be happy if most people had enough memory to just like keep the tables they currently have in memory rather than thinking that it would be, it would be, it would be a more, more appropriate reaction to try to specifically keep some tables in memory. Because, you know, you’re, you’re, you’re incurring a lot of potential technical debt when you could just incur some awesome RAM.

You could put things in memory and then everyone would be happy because they would say, oh, how much faster this is. I don’t have to wait on that crappy sand to get my data anymore. Or, my, my buffer pool is not constantly being flushed because of the 25 gig memory grant that this awful query asks for.

There are so many upsides to adding memory without, without adding it, or like without just pinning certain tables in there. And we’re good old B, DBCC pin table. Man, that was a blast.

You could, you could pin tables in memory. SQL Server wouldn’t argue with you. It didn’t help if things, if it was bigger than memory. Boom.

So one downside. One very big downside of DBCC pin table. No. I don’t even know. I don’t even think you can run that command anymore. Let’s go find out. I’m going to be rude for a second. Let’s see.

Let’s see here. DBCC. I know you can’t see my management studio. No, no, you can. Man, an incorrect number of parameters. I don’t even know. I don’t know if it still works, though. I have to go find that out somewhere. So I did group by yesterday.

The wonderful, lovely, action-packed, thrill-riddled group by online conference. That was a lot of fun. I had the 5 o’clock slot, which freaked me out because it was all the fault of time zones that I ended up there.

I thought it was at 1 p.m. So I was like, oh, I’m just going to hang out until 1, do the 1 o’clock thing, and then pass out. And then on the final speaker email, it was like, all times PDT. And I was like, oh, oh, my. That’s 5 p.m.

Oops. So I did that. I did some demos from my SQL Server performance tuning tasting menu, which I like because I can be completely incoherent in the demos that I do and string them together in whatever order I want.

And I can just talk until my time’s up. It’s a wonderful thing. So I ran out of time a little bit on the last one. I had like eight minutes left, and I was like, I can do this in eight minutes. And then I babbled too much. There’s someone outside yelling obscenities.

Whatever. Peter says, how often do you do client work where you aren’t allowed to use your usual tool set and are only allowed to use built-in default SSMS profile? I do most of my work in SSMS. So for me, it’s just a matter of, oh, God, excuse me.

Another side effect of antihistamines is that they are exhausting. So what I always say is, look, you might not like what I’m about to do. But I use the first responder kit stuff still.

So I used it before I worked for Brent, and I used it and worked on it while I was there. And I still use it and work on it now. So that’s like my primary tool set for doing things.

You know, there are some other queries that I’ll run if there’s a very specific problem that one of them turns up. But generally, you know, I just say, look, I’m going to install these scripts in the master database. It’s for expediency.

We have a limited amount of time together. I want to be as efficient and effective as possible and, you know, getting data, doing analysis on it. So look, I’m going to put these in master. When we’re done, you can delete them. You can get, we can wipe them out. You might see that they’re useful and want to keep them.

That’s fine too. But this is the way we’re going to work for a few hours today. And most people will just deal with it. Or like, I’ve met very little resistance to that. You know, some people are like, well, what are these scripts?

I’d be like, man, if you don’t know, if you don’t know, you’re not really in a place to like question, but you have the DBA title and you don’t know what ST Blitz is. I have serious concerns about how much you have, like, like what, what your job experience has brought you.

You should probably chill out. It’s not even an authority thing. It’s like, it’s like if, if, if I brought Advil to your house and you were like, I have a headache and I was like, take this Advil.

You were like, it’s Advil. Sounds untrusted. I don’t, I don’t trust your Advil. I don’t believe you. Yes, Peter, there is a cleanup script. Zane says, he sees people who don’t know SP who is active.

Yeah. Yeah, I know. Running to people who don’t have that either. There are times when I’ll just like reflexively type that in a window and hit F5 and they’re like, not found. Like, huh? Where am I? George says, Eric is the Advil for SQL Server.

Vitamin Advil. It’s my favorite. It’s my favorite vitamin. I don’t know. Would I be, would I be Advil? I don’t know. Maybe I’d be something spicier. Maybe like Percocets. Yeah.

Yeah. So Peter says he gets super bummed. I’m just gonna leave it at that. Peter gets super bummed. When he sees old versions of SP Blitz stuff. It’s, you know, it’s like, well, the one hand people are like, how could this get any better? This is so great.

Why would I ever need to update it? Yeah. Super old. Yeah. All this stuff. All this stuff. All this on fire, man. He’s been putting a ton of work into those things. I really like the stuff that he added to. Well, I mean, you could do, you can do backups and like in order and in parallel. You can have check DB run and like only hit a certain number of databases.

And then like only do databases that haven’t been hit yet. He added cool thresholds to rebuild stuff. And then by thresholds, I mean like a min and max number of pages.

So like min pages was always there, but max pages wasn’t. So you could have a table that’s so big. You’re like, no, I don’t, I don’t want to ever try to rebuild this. But it would just take, it would be too much work. Just leave it alone. And then also on the statistics stuff, Ola added.

So like before it was like you choose only modified statistics. And if like the modification counter was greater than one, you would go and mess with it. But he added like a percentage now. So you can, you can, you have a little bit more control over just how modified statistics have to be before they get updated.

I don’t know. There’s a lot of good stuff going on in there. I’m, I like all of it. I like all the stuff Ola has been doing. You know, especially it makes, it makes it a lot. I mean, you know, it’s more options. And so people might not be using them or using them correctly. But, you know, at least, at least when I, when I run into people who are using newer versions, I can be like, no, check out this thing.

We can, we can make this better and have that, have this run in a smarter way. It’s great. Something that maintenance plans haven’t done in a long time. Maintenance plans are just kind of the same old stupid. I don’t think I’ve seen maintenance plans change much since like 2014. And I think like the big change to the, they could, they could just like put stuff to Azure or whatever.

I’m like, come on. Come on. Come on. Come on. And George says, have you had a chance to play with ADR yet? ADR for those who don’t know is accelerated database recovery. Recovery.

I wish I, I wish you could put like a cool echo effect on my voice for that. I’m not that high tech though. Yeah. I think I have a YouTube video about me messing or a blog post about me messing with it. Uh, you know, I think, I think I like it. We’ll see how, we’ll see how things pan out.

You know, it’s one of those, it’s one of those features where like, you know, it’s really easy to show a nice demo of things like a nice, easy demo of it. Um, but I would imagine that there’s going to be all sorts of edge cases and race conditions and, you know, ineffective parts of it that will get sussed out.

You know, this is V1 release. No, it’s all right. V1, V1s are always rough. V1, a columnist or was garbage.

V1, our availability groups were brutal. So, so they’re all fine stuff, but there’ll be some bugs in there. You know, I say this because, you know, uh, like pretty much every, every V1 thing you hit weirdness with, you know, you know, or you hit like some, there’s like some, like even like to the state query store, if you put enough stuff in it, cleanup doesn’t run.

Uh, there’s like, like insane things happen to it and make it, it becomes unquery. It’s like, I’m not sure you will at times. Poor Joe Olbysh was telling, was talking about having one of the built-in reports run for over 30 minutes.

I’m like, yeah, work that out. I blogged about that too. Wow. Blogged about everything. SQL Dev DBA says, any recommendations for a team moving from enterprise, to enterprise from standard, uh, mainly data warehouse, just looking for recommendations from administration and tuning perspective.

Well, you know, I think it’s a funny question because, uh, there’s, there’s not a substantial difference between enterprise and standard anymore. And I’m going to, I’m going to caveat that in a few different ways, but what, what I’m going to compare it to immediately is Oracle, where with Oracle, there are very big differences.

And administration and, and tuning things that you have access to between standard and enterprise, different add-ons, different, different, you know, uh, different crates. You can open hopefully like some loot drops when you, when you do something really good.

Uh, but so there, that difference exists in that world, but with SQL Server, you primarily, you have the same tool set regardless of version. Um, and standard and enterprise. And then in 2016, uh, 2016, uh, 2016, 2016 SP1, uh, for standard edition, all of the, um, all of the, well, not all, but a lot of the programmability features became available though, like without like full hardware support.

So like you could do Hecaton and dedicate 32 gigs of memory to that. You could do columnstore and dedicate 32 gigs of memory to that. Um, you know, so there were, there were like, you didn’t get like transparent data encryption, but pretty much everything else you got.

Uh, so from perform from an administrative and tuning perspective, there’s not a whole lot of difference between, uh, surface area wise between enterprise and standard. So no, but you know, when people tell me they’re moving from standard to enterprise, I hope that they are embracing the new infinite hardware.

There that there’ll be, that there’ll be granted access to, you know, you can have however much, but like, you know, within like OS capacity reason, you can have, uh, you can have way more memory. You can use more CPUs, you can do all sorts of great stuff. You know, there’s, there’s cool things in there.

You know, there’s like merry-go-round scans, which aren’t available in standard edition. And not that I think those would be used a lot in the data warehouse. It’s not like, at least not often. There’s not like a lot of super concurrent activity where things might need to share reads, but who knows? You might have a special data warehouse.

Uh, but yeah, not really. Um, no, it’s, uh, I mean, some of the, the online, uh, capabilities are interesting, but you know, there’s like, if you need to like change tables, that might be a little bit easier, but I mean, no one, no one’s really rebuilding data warehouse indexes. That’s insanity.

It’s like insanity squared. Yeah. So, I mean, in a nutshell, no. Uh, no, let’s just leave it at that. Uh, let’s see.

Uh, mainly getting it because it includes power BI report server, but we’ll take advantage of other features too. All right. Well, there you go. Good luck with power BI. I refuse to open that thing. Uh, George says, do you have any cookie cutter techniques to increase performance on a system that uses an ORM and no store procedures also maxed off one. So cookie cutter?

Kind of. Uh, it depends on the ORM. So you tell me what the ORM is and then I’ll, I’ll, I might talk more about cookie cutter stuff. Sam says, when is your group by from yesterday going to be available?

I don’t know. They, I, they haven’t told me. I think it was usually within like a week before. I don’t know if that’s still true. Hopefully it is. Uh, I would like if it was within a week because then I could, I could put up a blog post. I’m like, I’m like, I’m just about a month out on blog posts, like, like a month of blog posts in the queue.

So it’d be nice to just get one more thing in there. Uh, and hibernate crap. That’s the one, that’s the one I don’t know a lot about. Um, so as far as I know and hibernate, as far as I remember and hibernate, uh, already does a pretty decent job with parameterization. Um, jeez.

Uh, oh, is that, I can’t remember now. I’m so sad that I can’t remember this. So there, there, there’s some difference in ORMs and, and the, the driver they use and in what they use to, uh, send queries to SQL. So like some will use SP execute SQL or SP prep exec.

And then others will use like SP prepare. And a while back, uh, uh, I’m going to try to see if I can find the blog post that I wrote about it, but I wrote about this a while back and how, um, uh, SP prepare is weird with performance in a way that, uh, SP, uh, execute SQL or SP prep exec isn’t. And that SP prepare essentially sends you a, uh, yeah, bingo.

So SP prepare sucks. And that it, the, the variables or the parameters for that get the density vector estimate. And, um, it, it, you often get very bad cardinality estimate guesses.

So check out the blog post link that I stuck in there. Uh, there’s a little bit more evidence behind that, but SP prepare, yeah, SP prepare can really ruin your day. So, um, uh, I’m not sure if you, if I’m not exactly sure where it is that you, if, if you can change how things are called. Uh, but that’s one thing that I’ve found can be difficult.

So, as far as cookie cutter stuff goes, changing the way in hibernate sends queries sometimes. Uh, yeah, doesn’t it though? Let’s see.

Uh, Josh says, and hibernate has a problem where it uses precise length string variables based on actual parameter value. So you can get lots of duplicate plans in the cache. Ah, yeah, that too. That’s, that’s, that’s a downer.

I wouldn’t, I wouldn’t want to do that. Um, I don’t, I don’t even think would let’s would force parameterization even help that. I don’t know. I don’t know when force parameterization would intercept that and make, make mealy worms out of it. Crazy.

Crazy. Crazy. Crazy. The insane things that people do with SQL Server databases. Huh? Right? Imagine if, imagine if the nice people in hibernate read my query. Or read my blog post about SP prepare and SP prep exec.

Imagine, imagine the world we live in. Oh, there’s one query I found the other day had 50,000 plans. Yeah, that’s not unheard of. Next, next thing I know you’ll be telling me that it calls cursors too.

Ha ha ha ha ha ha. Listen, everything that occurs for anyway. Everything that occurs for anyway. See, SazDV says I have 15 K instances of order hinting.

I bet it’s all SP who is active. I bet it’s all SP who is active. That’s what I always, I find that. Yeah. There, there are order hints that have you ever read through SP who is active ever in your life? There are so many hints and, and oh my God, it’s everything.

Adam, Adam was like off his ass when he wrote that. It was, there are temp tables that he creates one row statistics on. There are all sorts of joint hints.

There are all sorts of query hints like, like keep plan and keep fixed plan for like tape temp tables. It is insane when you read through it. There are, there’s even, there are even sections of SP who is active that call cursors that go through and do stuff. It is, it is whatever he, I don’t know what he was on when he wrote that.

I think he spent like a hundred hours. I forget how many hours it was either a thousand hours. Maybe he said on that. It was just like, wow. There are some incredible stuff in there, but yeah, he, he, he goes wild. Goes wild.

It was a, it was, it’s a joy reading through that. Um, one thing that I really like doing with SP who is active is if you ever want to have a really fun time with it, if you ever want to like see the query that it finally runs, uh, or like look at the execution plan for it. Uh, run it in a window and choose, um, show own speed.

Uh, like she, I think that’s the, that thing that’s a parameter. If you just choose show own speed and you turn on query plans. Uh, you can, you can see SP who is active running and you can see the query that it calls and you can see the query plan for it.

And it’s very funny to look through. Cause like when you, especially when you call it with like different parameters and it does different things within, within that is hysterical. The stuff that you see in there.

He hysterical. At least it makes me laugh. I, I, I get the giggles. When, when I read it. I stopped after the dynamic SQL and went maybe when I’m better at T SQL. Well, the thing is that I don’t think you can ever get good enough at T SQL to fully understand everything that Adam does.

Uh, the section where like section of code where he figures out agent job steps. It’s unreal, unreal, unreal. You have to like take, uh, like a, like a bar binary value and that’s in XML and convert it to like three different things.

And then like parse it out. It’s insane. What goes on in there? Like, I mean, you know, that’s talk, talk about hitting a mark. No one else could hit.

That’s what SP who was active did. And I don’t, I can’t think of anyone who could hit that mark. Now we’ve lost Adam to postgres. Postgres and Python. Will he ever return? Will he ever return?

I don’t know. I don’t know. I’d be happy if he’d returned to New York. Good. Use a dinner date. It’s a fun dinner date. I don’t know.

What are we doing here? It’s Friday. Where, why are you people working? You people doing more with your lives. Uh, did I miss anything in here? Not really.

Phillip Jones says, not having the diagnostics pack sucks. Yes, it does. Yeah. If you work with Oracle, if you work with SQL Server, you just, you have the same DMVs everywhere. Woo hoo. George says, I just got home. Well, how, I hope that, I hope you had a pleasant train ride, George.

I hope you had a, a license and a permit for that train ride and that you weren’t stopped by the constabulary. I’m very… Ticketed for any offenses. At least, you know, that’d be nice.

All right. It is close enough to 1230. Actually it is 1230. Why is this clock lying to me? The clock sucks. All right. So, it’s been a half hour. I’m going to get going.

I have another call soon. I don’t know. I’d like to wander around first before talking to anyone else. Thank you for joining. Thank you for all the great questions. I will hopefully see you next Friday. Same place.

Same time. Whatever. Forrest was here and he asked me nothing. Stink, Forrest. Stink. Stink.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I share some personal updates and reflections on my health and work life, while also diving into technical discussions about SQL Server. I start by talking about a recent bout of vertigo that has been affecting me, which led to the Epley maneuver for relief. This segues into a discussion on SQL Server performance tuning, specifically focusing on how version upgrades can sometimes lead to worse performance due to changes in cardinality estimators. I also address the topic of “optimized for sequential key” and its mysterious nature, as well as some interesting queries from viewers about database encryption and bulk inserts. Throughout the video, I offer advice on finding jobs that align better with one’s passions and how to handle imposter syndrome by writing things down and referencing facts more confidently. The technical portion includes practical tips on troubleshooting poor-performing queries and understanding encryption mechanisms in SQL Server environments like Azure. Overall, it’s a mix of personal anecdotes and professional insights aimed at helping DBAs and developers navigate their roles more effectively.

Full Transcript

I’m live, and I have my contacts in this week, so no glasses for you nice people. You get to see my face completely unfettered by shoddy Ray-Bans. So, lucky you. Lucky, lucky you. All 7,000 of you that have decided to join me today. On this glorious occasion of this splendid defeat. Ever think of LASIK? Yeah, I always think of LASIK. I mean, I always, uh, I don’t know what it is. Yeah, I would love to get LASIK. Another thing, yes, I would absolutely get LASIK. I would absolutely. get LASIK. I probably should get LASIK. I mean, I don’t drive, so I don’t have to worry about driving at night. I barely leave the house after dark. I don’t think walking at night would be an issue either. Mostly I’m afraid of like they, so there’s two things, I guess, because I have, I have a stigmatism. And so that automatically makes LASIK like three times as expensive or something. And, uh, the other thing is that I am afraid of, of them messing up and just like shooting a laser through my eyes. So. Sometimes, sometimes I, I really wanna, but then I’m like, eh, you know.

I’d rather be able to see poorly than have, have holes in my face where my eyes used to be. Laser holes in my face. There’s other stuff that I would, I would like to get surgically fixed first. Like, I just wish someone would take a drill and like make my ear canals better. My ears are awful.

I, uh, I woke up in the middle of the night on Sunday spinning, which is not that unusual of an occurrence, but it was like particularly bad. And, uh, I, I, I realized that I had vertigo, not just alcohol induced spins. I had, I had like legit vertigo. I had like, I hadn’t felt that way. I guess the last time I had felt even remotely like that was when, uh, Brent took people on the Alaskan cruise. And the first night at sea, the boat was, uh, the first night at sea, the boat was at all sorts of bizarre angles, flitting and floating around.

And, uh, I was, I was seasick for like a month after that. Uh, so when this, when this happened, it was like significantly, it was like acute vertigo. It was not intractable. It was just acute. And, uh, so I had to do this thing called, uh, the hell is it called again? Hang on. Hang on. Hang on. Hang on. I’m going to go look this up. Uh, vertigo maneuvers. What’s it called?

The Epley maneuver. E-P-L-E-Y. Epley maneuver. And I had to like lay back with my head hanging off the bed and like turn it and turn and turn my head and flip around. It was, it worked. Gosh darn it. It worked. Worked wonderfully. Uh, the acuteness of the vertigo has subsided to just slightly mild nausea. So that’s nice.

Uh, I’m just, I’m just cramming Dramamine and Advil in my head now. So whatever. It’s fun. It’s fun. Today’s the first day that I have not felt significantly dizzy since Monday. Hopefully I’m on the, hopefully I’m on the mend. I haven’t been going to the gym because, uh, I, I’ve been unsteady on my feet.

That seems like a pretty bad time to, you know, squatter, deadlift or overhead press, any of those things. Anyway. That was, that’s my, that’s been my fun week so far.

If I’ve seemed, uh, cranky or short in any, in any venue this week, probably because I’ve just been, uh, sick and on Dramamine for the entire week. Dude, how you’re getting better. Thanks, Rowdy.

I’m going to assume you meant hope. At least, you know, partially assume you meant hope. I don’t know. Hope is a useless venture.

Yeah, yeah, yeah. All right. Someone, it’s been five minutes of me talking about being dizzy. Someone, someone asked me a SQL Server question before, before I have no attendance whatsoever. Not, not, not doing my dancing monkey routine and making people, making, hopefully making people’s lives easier.

Is they interact with the incredible piece, the incredible feat of engineering known as Microsoft SQL Server. That has, somehow has worse partitioning than Postgres. Far worse partitioning than Oracle.

Far worse partitioning than probably DB2. I say that without ever having used DB2. I could be completely wrong. I’m going to put an asterisk on that one.

Farrest asks a question near and dear to my heart. How often do you see version upgrades leading to worse performance? Man.

That’s, that happens a lot. That new cardinality estimator is just… I would like to, I would, I would, I would like an intimate look at the workloads that it helps.

I mean, granted, the legacy cardinality estimator certainly messed a lot of stuff up. And the certain, legacy cardinality estimator was certainly never completely perfect. That’s why they worked on the new one.

But I would really like to know exactly what kind of workload the new one is, like, super beneficial for. Because when, when, when I look at, like, the workloads that, that tank when they use it, like, this isn’t that bad. You’re not doing anything weird.

You’re not, like, like messing things up in any way that other people aren’t messing things up. Like, what makes this cardinality estimator so much worse for you? And this is after flailing at stuff like stats updates and, like, like changing indexes and, like, moving chunks of code around.

And it’s like, this is still not good. Something is a muck here. So pretty often, yeah.

And it’s like, it’s not like I want to spook people away from using the new cardinality estimator. It’s just, you have to really, really test that thing out. And you have to really pay close attention to what, which, to which queries, how they behave under the different cardinality estimator. I’ve seen somewhere it’s just, like, nothing changed, really.

It’s like, it’s disappointing. Coming for fireworks of some kind. This is, like, something to go, like, miraculously bad or something to go, like, miraculously right. It’s going to happen.

This is, like, the same thing. Like, there’s, like, a hundred row difference in the estimate. I’m like, oh, it’s not exciting. Then again, very few people want excitement out of SQL Server.

Very few people are like, excite me. Everyone’s just like, please just stay, just be quiet. Just don’t do anything awful. It’s like having a baby in a restaurant.

Please just be quiet and don’t cry and don’t, like, pull the tablecloth off the table or, like, knock any glasses over. Just please just, like, sit and be cute and quiet. Peter, my goodness.

Did you ever get more or juicier details on optimized for sequential key? Saw one pretty sparse follow-up on the announcement. Nothing since.

No, I haven’t gotten anything new on that. You know, there was a blog post kind of going through how it worked, which, you know, I guess for something that’s patented, you know, something that’s, like, secret sauce. It gave an okay amount of detail.

I mean, it’s probably, you know, not going to be enough unless you can, you know, look at source code and debuggers and all sorts of other fun stuff. But, you know, no, no, I haven’t gotten anything. Then again, very few people willingly give information to me.

Very few people are, like, let me volunteer you this information. I don’t know. I try to get on the cool kid lists where people are, like, let me tell you how this works.

But, you know, cool kid lists won’t happen. Chloe. How are we doing?

What was I going to say? Yeah, I went for a walk. I went for a walk this morning. Pleasant walk.

Hi. Lee says, I’m troubleshooting a poor-performing query. When I ran spwhoisactive with getlocks equals one, I see the following database.encryption scan. Did someone turn on?

Did someone try to turn it on? Did someone try to use it in some way? I’m curious about that. It sounds like someone is trying to turn on TDE or someone is trying to use, like, always encrypted or something. So that’s cute.

That’s curious. I don’t know. Let’s see. Hmm. Yeah.

It looks like someone was trying to turn on TDE of some kind. I’m going to stick you, stick the first thing I found into chat because it sounds promising. Yeah.

Unfortunately, there’s very little else that that could mean. It’s most likely related to either, like, TDE or column-level encryption or cards outside trying to beat my foul language. Yeah.

It’s about it. There’s not a lot else that causes that. Azure. Ooh. The plot thickens. I don’t know.

Does Azure use, like, some sort of encryption in the background that we don’t know about? I wonder if it was for, like, maybe it’s for, like, a system database or something. I bet, you know, it would make a certain amount of sense if Azure, like, encrypted your local system databases.

I’m going to get my thinking juice in. Column-level encryption is present with that. It sounds like a good place to start troubleshooting.

It sounds to me like something that might give you an encryption scan. That would be the next direction that I pointed my troubleshooting efforts in. Further than that, I don’t know because I do nothing with security.

It’s wonderful. It’s wonderful to not ever touch security. I never have to worry about securing anything.

All I have to worry about is making something faster. It’s like, yes. It’s great. I get to sit around with all my fun tricks, learn some new tricks. Justin Patterson says, bulk insert on a table with a date time column, default get date.

All dates are the same. Yeah. So when it’s in a transaction like that, when you do bulk insert, you’ll get all the same values for stuff like that. So even if you had other default values for like Rand, I think new ID might be.

Actually, I don’t know. I was going to say new ID might be the only thing that’s immune to that, but I’ve never actually tried it. So I don’t want to promise you anything.

That makes sense to me if you’re bulk inserting. SQL Server is probably like, yeah, get date. All right. The reason that I want to say that that is the way it goes is because in the Stack Overflow example database, the votes table, there’s a creation date column that is a date time.

And there is only ever like a single, there’s like, it’s all like chunks of a single date value that ends up in there. There is like no, never any like value for the timestamp. It’s all like full somethings.

Just like dates with no time attached to them. And I think that’s because there’s a bulk insert process that goes there. That’s all I know. That’s all I know, I’m sticking to it.

I’ve had other, there are other columns that have non-deterministic functions like that that will not give you different values on insert. You have to like feed them something to get different values. He says, I want to practice performance tuning and keep getting roped into nonsense, i.e. stuff that bores me.

Why would I ignore that message? That’s a great message. Get a job where you get, stop getting roped into stuff that annoys you. That’s the best way to do it.

Look for jobs where they’re like, we need people to performance tune this database and say, I want to focus on performance tuning. The reason that I want to leave this job is because I do not get to do enough performance tuning, which is my passion with SQL Server. And so I end up getting roped into figuring out why someone is trying to turn on TDE and why that person has privileges to turn on TDE in this database that I’m trying to performance tune.

You have a junior now. Congratulations. Mazel tov.

Hope juniors a healthy baby. And you can make them get roped into the stuff that bores you so that they can leave as soon as possible. So one thing you have to be careful of with those juniors, if they get bored, they’re going to not lie.

They might exaggerate their experience in their time with your company when they start looking for new jobs. And it’s, oh, you know, I’ve been, boy, I’ve been working hard at this DBA thing for a long time. Imposter syndrome is now 100%.

I don’t believe in imposter syndrome. Just don’t. I think what a lot of people confuse for imposter syndrome is a lack of confidence in their knowledge about certain things. And while I think that’s certainly an understandable thing to have, and that’s certainly probably a good way to stay on your toes about things.

There are times when it hits me, and I used to think that it was imposter syndrome when someone would, like, say something that was wrong. And I would know that it’s wrong. But, like, hearing someone else say it would make me question whether or not I knew my stuff.

And I used to think, man, I feel that must be imposter syndrome. Maybe, I don’t know. Maybe it feels different to other people.

But that’s always what it struck me as. And over time, I sort of got more confidence in the stuff that I know. And I started writing things down more so that I could be more confident in it. And that seemed to help.

Writing things down is helpful. Being able to reference facts and correctness is helpful. So don’t feel like an imposter. You know, we’re all continuing to learn, except people who work with TDE, because they have very little to learn.

And then they’re done. And then they can go back to, like, playing chess in a park or whatever. Go back to ranting at pigeons.

And, you know, so, like, whenever that happens to me now, and, you know, it’s probably easier for me to do this as a consultant. So whenever someone says something that I know to be demonstrably false about SQL Server or databases or computers in general, what I always do is say, all right, can you, like, can you show me where you read that?

Like, can you show me, like, can you show me some source for your information? Or if they were, like, well, I tested it. I’m, like, I’d love to see it.

Can you show me your test? Like, can you show me what you did that led to that conclusion? And very often, those people will go silent. The whole show me your work thing leads to a lot of people just quitting and giving up.

Like, I don’t have it anymore. It’s a long time ago. I have to go check my email or something like that. I have to dig through my scripts folder.

Okay. I’ll wait on that. We’ll be over here waiting for you. Pantelis says, I found this.

And then, ah, there we go. Oh, oh, we had to split up the message. I see now. In Azure, all newly created SQL databases are encrypted by default. And the database encryption key is protected by a built-in server certificate.

Certificate maintenance and rotation are managed by the service and require no input from the user. Jeez. Like, no input from the user is just like, I would really like this maintenance to not happen while I’m trying to performance doing the database.

It seems like a strange thing to not get user input on. I would want input on that. It seems like if someone was going to be doing that sort of thing on a database that I was working on, I would be like, hey, I have input on when I would like this to happen.

If you see SB who is active running, stop doing what you’re doing. Something bad is happening. It could be, like, I still think it’s going to be like a system database maybe.

Or the column level encryption thing that you said you’re using. Who knows? All sorts of fun stuff going on there. All sorts of fun stuff going on up in the cloud.

All sorts of fun stuff. Does anyone else have a SQL Server question? Come on.

There are a billion of you out there. One billion. You’re not spamming chat. There’s no spam, please. Ask all the questions you want.

There is nothing else in here. He said I have a stinky update statement which has a function being used. For example, update my table set my field equals write my field 1.6.

My table has around 10 million records in it. I know the best thing here would be to remove the function entirely, but I can’t do that. Is there any way I can prove this?

Only way I have been able to improve this is to do something like set my field equals write. Yeah.

So the function, built-in functions. Let me be very clear about this. Built-in functions like write, left, substring, date, add, date, time. And that situation don’t have the same kind of overhead that, like a user-defined function of this scalar or multi-statement like the at sign table variable returning type would.

Those functions don’t really trouble queries too much unless you put them in a where clause. Now, granted, like how you’re doing it in the where clause might be helpful in that even though you have to scan all 10 million rows, you probably rule some of those 10 million rows out.

So what I would do is rather than update your table with that, I would add a computed column. Not persisted, just a computed column. So you could add, you know, it’s an alter table, my table.

Add my field computed as case when my field 2 is not equal to write my field 1, 6, then write my field 1, 6. And that would be instant, as long as you don’t persist it, that would be instantaneous.

And then you could index that column. You could do all sorts of fun stuff to that column. You wouldn’t have to go and update the entire table.

You would just have this virtual column sitting on your table that has that on there. No, that would, no, no. Those, the built-in functions are CLR.

They’re CLR. Let’s just call them CLR-ish. They’re behind the scenes. They are C Sharp. They take advantage of .NET stuff, and they don’t, they don’t, they don’t force anything to run serially. So, no.

You don’t have that problem there. The only thing that forces, I mean, there are a few things that force serialization. Right now, the most common is scalar user-defined functions. Modifying table variables in 99% of circumstances.

Global aggregates. Certain system views. The recursive part of a recursive CTE. Gosh, a whole bunch of stuff.

Top, when it’s outside of a cross-supply. Justin says, how do you pronounce S-A-R-G ability? How do I pronounce that word?

Sargability. Search argument. Sargability. If anyone says Sargability, ask them if they pronounce argument, argument. Or if they, I guess that’s it.

And then if they want to argue with you about it, you can say, well, that’s not how you pronounce argue. Ijit. That’s my advice.

You have heard S-Argability? The hell said that? You have my permission to throw eggs at whoever pronounces it that way. How do you pronounce G-I-F?

That depends on where I am in the world. In France, it is les GIFs. In certain parts of rural America, it is GIF.

In other parts, depending on local colloquialisms, it could be GIF or GIF or GIF. It kind of depends on where you are. Local factors apply.

Okay. Local factors apply to that. There’s no, I mean, there might be. There might be an intended way to pronounce that.

But, you know, all sorts of things happen when words are culturally embraced by people who speak differently, speak different languages. So, really, you know, hard Gs and soft Gs don’t exist in every single tongue. Some, I’ve heard that there are some languages out there that don’t have the letter G in them at all.

They’ve skipped over it entirely. So, how do you pronounce that? How do you pronounce that word if you don’t, if you haven’t invented the letter G? It’s a tough one.

It’s a tough one. You know, most importantly, there is an I in GIF, and I decide how I’m going to say that one. Greek have no letter G.

Isn’t that ironic? So, they’re just reeks. That’s weird, because I know several Greek people.

Well, I guess, I guess, I mean, they’re named like Giorgio or something. Or George, George, George something, Georgious, Giorgio, Giorgio, or Georgie, something like that. I don’t know.

I’ve given up on learning new languages. I’m just no good at it. I can’t even learn JavaScript. Talk about how tough life is.

But in English, G is not associated with a single sound. No, G is associated with many sounds, including sounds that aren’t like, you know, G alone, like ing. Like, there’s no G sound, like ing, ing, ing.

Like, talking, texting, walking. There’s a G in there. Josh has announced his presence, thank goodness.

I was wondering how I was going to develop an ulcer without you. Now that you’re here, you better ask a good question. Which you won’t, because you’re lazy.

You didn’t come prepared. Yes, today’s episode is brought to you by the letter G. Like, G, I wish I was sitting somewhere drinking.

Gosh darn it. I want to go drink. Golly and gosh. Glass of wine sure would be great.

Grandma’s gin, Ginny Gums, Gristle Grimly. Gee, I’m still at work. It’s 1230 here.

Oh, it’s like 530 there, I think. Unless you have a weird daylight savings time thing going on. It’s 530 there, I think. I think UK is five hours ahead.

France is six. Wilson says, I saw this on Reddit today. You have any tools you use? What?

Tools. I got a whole box of tools behind those nagels that someday I’m going to use to hang up those nagels. But I have to buy a piece of furniture for over here first. My office underwent a half-assed redesign before I went on vacation for a month.

I got a new standing desk. And I threw up my old desk, which was like an L shape. And it had a bunch of drawers and storage in it.

So now I have my old standing desk riser put up to maximum height. And I’m using that as ghetto shelving until I decide on what kind of piece of furniture I’m going to use over here to put my stuff on. And then when I get that, I can make more permanent choices about where Ren and Stimpy and the nagels will go.

And that’s how dull my life is. I don’t know. It’s awful.

Josh asks, if a query’s duration and CPU usage increases according to Query Store, there’s your first problem. Never trust a query store. But nothing else does.

With the same plan, same logical reads, dop, et cetera, what could that mean? Well, if it’s the same reads, that rules a lot of things out like index fragmentation. And if duration and CPU are both going up, then that rules out external forces like blocking, in which case duration would increase and CPU would stay the same or maybe even go down.

Let’s see. What could cause that? Maybe.

Well, it’s the same plan. Well, actually, that could make sense. What if, I mean, you could be, what if you’re just dealing with more data? Or, I guess what I might be interested in is, if it’s the same plan, are you hitting parameter sniffing?

Remember that one? Remember parameter sniffing? That thing that you learned about in high school?

That was glue sniffing. Yeah. All right. Well, I mean, it sounds like it could be parameter sniffing. It could be. I don’t really know what else to make of that.

If it’s the same plan, and reads aren’t, oh, well, reads aren’t going up, so parameter sniffing would probably rule that out. Yeah. It’s a VM.

Oh, boy. Okay. So, if you’re on SQL Server 2017, if you’re on SQL Server 2017 and using Query Store, you might want to join off to that aggregate wait stats view, like Query Store wait stats, to see if there are different waits involved for different iterations of this query. That’s what I’d point to.

That’s what I’d point to. But you’re probably on 2016, and I’m going to be disappointed in you. Oh, good idea. I finally had one of those.

I’m so happy when I have a good idea. Happens once a year. Once a year. My good idea for last year was, well, it’s still this year. Crap.

I guess I have two good ideas this year. Actually, three. One is, I didn’t get a real job. Two is, I had temporary tattoos made for swag. And three is, check the wait stats.

It’s funny, because I hate wait stats. Josh wonders aloud if SOS scheduler yield, like CPU contention or an oversubscribed VM, would be included in CPU time. Maybe.

Maybe. I would also look at what that query is doing, because, well, it might need to read like a fairly set amount of data.

I don’t know. Is it? I’m always curious when, like, a query is, like, really CPU intensive without being really read intensive. Like, what are you up to in there?

Like, all your data is in memory if you’re not doing, like, a lot of reads. Grumbling monster behind me. All your data is in memory.

If you’re just, like, purely pushing CPU, that’s one thing. I wonder if this query is parallel or serial, if the plan is parallel or serial. And I would wonder further if there are other issues involved.

I don’t know. We’ll have to wait for this. This sounds like a good question for dba.stackexchange.com, a site you may or may not have heard of, for data professionals.

A parallel plan. Let’s see. It’s from an SE question.

You thief! You liar! Come here with bootleg questions. I had to shoot you. Shoot you like the scoundrel you are. It’s a parallel plan.

Well, if it’s someone else’s question, I’m going to assume you don’t have access to run the query and see if there is perhaps some issues with the parallelisms of the query. Like, perhaps some spillage or some skewedness across different things. Because that would certainly explain why CPU and duration would go up without a meaningful increase in reads.

I would want to know. So here’s what I would, here’s where I would dig in. Right?

Reads are the same. Yeah, reads are the same. Same plan. Same dot. Duration and CPU are going up.

Tell me if that query is doing any writes. Tell me if that query is spilling or spooling or doing something else. Tell me if that, like, you know, there’s no way to see it now.

But now it’s like all these, all these things that, like, queries that when selects cause rights, that’s, that’s in my head now. And I’m thinking, like, well, I don’t know, like, like, are you updating stats behind the scenes sometimes? Are you, are you doing some other labor intensive tasks that wouldn’t show up traditionally with a query?

Right? Wouldn’t, wouldn’t, wouldn’t impact query runtime. Wouldn’t, like, show up as, like, a query weight.

It would just be, we did, we had more CPU associated with us behind the scenes. But, you know, we don’t have a good way of finding that out. So I would want to know if that query is performing writes of any kind.

That’s, that would be my next thing. I.O. completion weights would be something to look into. Because that’s usually our sleep task.

So I.O. completion would be, like, sort spills. Sleep, sleep task would be, like, hash spills. There’s no way to tell behind the scenes if it’s updating stats or something when the query runs. But, you know, depending on what goes on there, that could be, could be a drag.

Be quite a drag. Ha ha ha ha ha ha ha. So, yeah. That’s what I would, that’s, that would be, that would be my, the next place that I went to look at. My troubleshooting repertoire.

Like, what’s going on behind here? Oh, man. That was exhausting. It is a select into.

Okay. Well. We’ve, we’ve, we’ve certainly started to piece together slowly but surely. What, what is, what might be going on with this query?

So now we have a select into. Are we selecting into a user database or into a temp table? Do we have additional contention in this user, user database or in this temp table for some reason? Do we have anything that might be blocking writes to this table?

I know it’s a select into. But if you have snapshots occurring, like snapshot backups occurring, they’re quiescing activity. Well, because no, it’s, no, they’ll be blocking.

Never mind. We’re back to the CPU and duration going up and nothing else. Arr. Just trying to crowdsource my answer so I can get more rep than you. Ah, just go ahead.

I’ll, if I could bounty all my rep away and live like a stack exchange hermit, I would. But I do not have the patience to give my rep away like 500 points at a time. One day at a time.

I don’t think you, like you can’t have multiple bounties open at once. Forrest brings up an interesting point. If there’s only a small amount of space available in the database, does SQL Server have to spend more time writing disjoint extents?

How about this one? Does SQL, if SQL Server has to grow when, that has to grow the database and you do the select into? That’s certainly something that I don’t know that, like, I don’t know if that would count towards query CPU and duration.

Like, definitely query duration. I’m not sure if that would count towards query CPU. But if we had to grow the database and, and growths were slow in the database, like, let’s say, you know, a database, database was good.

Like, instant file initialization wasn’t turned on or, so instant file wasn’t turned on, you’re expanding the data file behind the scenes. That might be something. Another thing is, if the log file has to grow, that’s, I mean, instant file initialization never helps that.

So, if behind the scenes, we’re having to grow the transaction log, that could, that could certainly add. And, like, again, like, the part that I’m not sure on is if that would count towards query runtime. I’ve never cared enough to figure that out.

Maybe, maybe I do now. Or maybe that would make a good blog post for someone with a burning question on their mind. I don’t know that it’s quite burning for me yet.

What is burning is how hungry I am. That I’ve been talking for 40 minutes. 10 minutes longer than my usual webcast length. And I’m going to go eat now.

So, thank you for hanging out. I hope you had a time good with your face parts. Bye. Bye.

Bye.

Video Summary

In this video, I share some personal updates and reflections on my health and work life, while also diving into technical discussions about SQL Server. I start by talking about a recent bout of vertigo that has been affecting me, which led to the Epley maneuver for relief. This segues into a discussion on SQL Server performance tuning, specifically focusing on how version upgrades can sometimes lead to worse performance due to changes in cardinality estimators. I also address the topic of “optimized for sequential key” and its mysterious nature, as well as some interesting queries from viewers about database encryption and bulk inserts. Throughout the video, I offer advice on finding jobs that align better with one’s passions and how to handle imposter syndrome by writing things down and referencing facts more confidently. The technical portion includes practical tips on troubleshooting poor-performing queries and understanding encryption mechanisms in SQL Server environments like Azure. Overall, it’s a mix of personal anecdotes and professional insights aimed at helping DBAs and developers navigate their roles more effectively.

Full Transcript

I’m live, and I have my contacts in this week, so no glasses for you nice people. You get to see my face completely unfettered by shoddy Ray-Bans. So, lucky you. Lucky, lucky you. All 7,000 of you that have decided to join me today. On this glorious occasion of this splendid defeat. Ever think of LASIK? Yeah, I always think of LASIK. I mean, I always, uh, I don’t know what it is. Yeah, I would love to get LASIK. Another thing, yes, I would absolutely get LASIK. I would absolutely. get LASIK. I probably should get LASIK. I mean, I don’t drive, so I don’t have to worry about driving at night. I barely leave the house after dark. I don’t think walking at night would be an issue either. Mostly I’m afraid of like they, so there’s two things, I guess, because I have, I have a stigmatism. And so that automatically makes LASIK like three times as expensive or something. And, uh, the other thing is that I am afraid of, of them messing up and just like shooting a laser through my eyes. So. Sometimes, sometimes I, I really wanna, but then I’m like, eh, you know.

I’d rather be able to see poorly than have, have holes in my face where my eyes used to be. Laser holes in my face. There’s other stuff that I would, I would like to get surgically fixed first. Like, I just wish someone would take a drill and like make my ear canals better. My ears are awful.

I, uh, I woke up in the middle of the night on Sunday spinning, which is not that unusual of an occurrence, but it was like particularly bad. And, uh, I, I, I realized that I had vertigo, not just alcohol induced spins. I had, I had like legit vertigo. I had like, I hadn’t felt that way. I guess the last time I had felt even remotely like that was when, uh, Brent took people on the Alaskan cruise. And the first night at sea, the boat was, uh, the first night at sea, the boat was at all sorts of bizarre angles, flitting and floating around.

And, uh, I was, I was seasick for like a month after that. Uh, so when this, when this happened, it was like significantly, it was like acute vertigo. It was not intractable. It was just acute. And, uh, so I had to do this thing called, uh, the hell is it called again? Hang on. Hang on. Hang on. Hang on. I’m going to go look this up. Uh, vertigo maneuvers. What’s it called?

The Epley maneuver. E-P-L-E-Y. Epley maneuver. And I had to like lay back with my head hanging off the bed and like turn it and turn and turn my head and flip around. It was, it worked. Gosh darn it. It worked. Worked wonderfully. Uh, the acuteness of the vertigo has subsided to just slightly mild nausea. So that’s nice.

Uh, I’m just, I’m just cramming Dramamine and Advil in my head now. So whatever. It’s fun. It’s fun. Today’s the first day that I have not felt significantly dizzy since Monday. Hopefully I’m on the, hopefully I’m on the mend. I haven’t been going to the gym because, uh, I, I’ve been unsteady on my feet.

That seems like a pretty bad time to, you know, squatter, deadlift or overhead press, any of those things. Anyway. That was, that’s my, that’s been my fun week so far.

If I’ve seemed, uh, cranky or short in any, in any venue this week, probably because I’ve just been, uh, sick and on Dramamine for the entire week. Dude, how you’re getting better. Thanks, Rowdy.

I’m going to assume you meant hope. At least, you know, partially assume you meant hope. I don’t know. Hope is a useless venture.

Yeah, yeah, yeah. All right. Someone, it’s been five minutes of me talking about being dizzy. Someone, someone asked me a SQL Server question before, before I have no attendance whatsoever. Not, not, not doing my dancing monkey routine and making people, making, hopefully making people’s lives easier.

Is they interact with the incredible piece, the incredible feat of engineering known as Microsoft SQL Server. That has, somehow has worse partitioning than Postgres. Far worse partitioning than Oracle.

Far worse partitioning than probably DB2. I say that without ever having used DB2. I could be completely wrong. I’m going to put an asterisk on that one.

Farrest asks a question near and dear to my heart. How often do you see version upgrades leading to worse performance? Man.

That’s, that happens a lot. That new cardinality estimator is just… I would like to, I would, I would, I would like an intimate look at the workloads that it helps.

I mean, granted, the legacy cardinality estimator certainly messed a lot of stuff up. And the certain, legacy cardinality estimator was certainly never completely perfect. That’s why they worked on the new one.

But I would really like to know exactly what kind of workload the new one is, like, super beneficial for. Because when, when, when I look at, like, the workloads that, that tank when they use it, like, this isn’t that bad. You’re not doing anything weird.

You’re not, like, like messing things up in any way that other people aren’t messing things up. Like, what makes this cardinality estimator so much worse for you? And this is after flailing at stuff like stats updates and, like, like changing indexes and, like, moving chunks of code around.

And it’s like, this is still not good. Something is a muck here. So pretty often, yeah.

And it’s like, it’s not like I want to spook people away from using the new cardinality estimator. It’s just, you have to really, really test that thing out. And you have to really pay close attention to what, which, to which queries, how they behave under the different cardinality estimator. I’ve seen somewhere it’s just, like, nothing changed, really.

It’s like, it’s disappointing. Coming for fireworks of some kind. This is, like, something to go, like, miraculously bad or something to go, like, miraculously right. It’s going to happen.

This is, like, the same thing. Like, there’s, like, a hundred row difference in the estimate. I’m like, oh, it’s not exciting. Then again, very few people want excitement out of SQL Server.

Very few people are like, excite me. Everyone’s just like, please just stay, just be quiet. Just don’t do anything awful. It’s like having a baby in a restaurant.

Please just be quiet and don’t cry and don’t, like, pull the tablecloth off the table or, like, knock any glasses over. Just please just, like, sit and be cute and quiet. Peter, my goodness.

Did you ever get more or juicier details on optimized for sequential key? Saw one pretty sparse follow-up on the announcement. Nothing since.

No, I haven’t gotten anything new on that. You know, there was a blog post kind of going through how it worked, which, you know, I guess for something that’s patented, you know, something that’s, like, secret sauce. It gave an okay amount of detail.

I mean, it’s probably, you know, not going to be enough unless you can, you know, look at source code and debuggers and all sorts of other fun stuff. But, you know, no, no, I haven’t gotten anything. Then again, very few people willingly give information to me.

Very few people are, like, let me volunteer you this information. I don’t know. I try to get on the cool kid lists where people are, like, let me tell you how this works.

But, you know, cool kid lists won’t happen. Chloe. How are we doing?

What was I going to say? Yeah, I went for a walk. I went for a walk this morning. Pleasant walk.

Hi. Lee says, I’m troubleshooting a poor-performing query. When I ran spwhoisactive with getlocks equals one, I see the following database.encryption scan. Did someone turn on?

Did someone try to turn it on? Did someone try to use it in some way? I’m curious about that. It sounds like someone is trying to turn on TDE or someone is trying to use, like, always encrypted or something. So that’s cute.

That’s curious. I don’t know. Let’s see. Hmm. Yeah.

It looks like someone was trying to turn on TDE of some kind. I’m going to stick you, stick the first thing I found into chat because it sounds promising. Yeah.

Unfortunately, there’s very little else that that could mean. It’s most likely related to either, like, TDE or column-level encryption or cards outside trying to beat my foul language. Yeah.

It’s about it. There’s not a lot else that causes that. Azure. Ooh. The plot thickens. I don’t know.

Does Azure use, like, some sort of encryption in the background that we don’t know about? I wonder if it was for, like, maybe it’s for, like, a system database or something. I bet, you know, it would make a certain amount of sense if Azure, like, encrypted your local system databases.

I’m going to get my thinking juice in. Column-level encryption is present with that. It sounds like a good place to start troubleshooting.

It sounds to me like something that might give you an encryption scan. That would be the next direction that I pointed my troubleshooting efforts in. Further than that, I don’t know because I do nothing with security.

It’s wonderful. It’s wonderful to not ever touch security. I never have to worry about securing anything.

All I have to worry about is making something faster. It’s like, yes. It’s great. I get to sit around with all my fun tricks, learn some new tricks. Justin Patterson says, bulk insert on a table with a date time column, default get date.

All dates are the same. Yeah. So when it’s in a transaction like that, when you do bulk insert, you’ll get all the same values for stuff like that. So even if you had other default values for like Rand, I think new ID might be.

Actually, I don’t know. I was going to say new ID might be the only thing that’s immune to that, but I’ve never actually tried it. So I don’t want to promise you anything.

That makes sense to me if you’re bulk inserting. SQL Server is probably like, yeah, get date. All right. The reason that I want to say that that is the way it goes is because in the Stack Overflow example database, the votes table, there’s a creation date column that is a date time.

And there is only ever like a single, there’s like, it’s all like chunks of a single date value that ends up in there. There is like no, never any like value for the timestamp. It’s all like full somethings.

Just like dates with no time attached to them. And I think that’s because there’s a bulk insert process that goes there. That’s all I know. That’s all I know, I’m sticking to it.

I’ve had other, there are other columns that have non-deterministic functions like that that will not give you different values on insert. You have to like feed them something to get different values. He says, I want to practice performance tuning and keep getting roped into nonsense, i.e. stuff that bores me.

Why would I ignore that message? That’s a great message. Get a job where you get, stop getting roped into stuff that annoys you. That’s the best way to do it.

Look for jobs where they’re like, we need people to performance tune this database and say, I want to focus on performance tuning. The reason that I want to leave this job is because I do not get to do enough performance tuning, which is my passion with SQL Server. And so I end up getting roped into figuring out why someone is trying to turn on TDE and why that person has privileges to turn on TDE in this database that I’m trying to performance tune.

You have a junior now. Congratulations. Mazel tov.

Hope juniors a healthy baby. And you can make them get roped into the stuff that bores you so that they can leave as soon as possible. So one thing you have to be careful of with those juniors, if they get bored, they’re going to not lie.

They might exaggerate their experience in their time with your company when they start looking for new jobs. And it’s, oh, you know, I’ve been, boy, I’ve been working hard at this DBA thing for a long time. Imposter syndrome is now 100%.

I don’t believe in imposter syndrome. Just don’t. I think what a lot of people confuse for imposter syndrome is a lack of confidence in their knowledge about certain things. And while I think that’s certainly an understandable thing to have, and that’s certainly probably a good way to stay on your toes about things.

There are times when it hits me, and I used to think that it was imposter syndrome when someone would, like, say something that was wrong. And I would know that it’s wrong. But, like, hearing someone else say it would make me question whether or not I knew my stuff.

And I used to think, man, I feel that must be imposter syndrome. Maybe, I don’t know. Maybe it feels different to other people.

But that’s always what it struck me as. And over time, I sort of got more confidence in the stuff that I know. And I started writing things down more so that I could be more confident in it. And that seemed to help.

Writing things down is helpful. Being able to reference facts and correctness is helpful. So don’t feel like an imposter. You know, we’re all continuing to learn, except people who work with TDE, because they have very little to learn.

And then they’re done. And then they can go back to, like, playing chess in a park or whatever. Go back to ranting at pigeons.

And, you know, so, like, whenever that happens to me now, and, you know, it’s probably easier for me to do this as a consultant. So whenever someone says something that I know to be demonstrably false about SQL Server or databases or computers in general, what I always do is say, all right, can you, like, can you show me where you read that?

Like, can you show me, like, can you show me some source for your information? Or if they were, like, well, I tested it. I’m, like, I’d love to see it.

Can you show me your test? Like, can you show me what you did that led to that conclusion? And very often, those people will go silent. The whole show me your work thing leads to a lot of people just quitting and giving up.

Like, I don’t have it anymore. It’s a long time ago. I have to go check my email or something like that. I have to dig through my scripts folder.

Okay. I’ll wait on that. We’ll be over here waiting for you. Pantelis says, I found this.

And then, ah, there we go. Oh, oh, we had to split up the message. I see now. In Azure, all newly created SQL databases are encrypted by default. And the database encryption key is protected by a built-in server certificate.

Certificate maintenance and rotation are managed by the service and require no input from the user. Jeez. Like, no input from the user is just like, I would really like this maintenance to not happen while I’m trying to performance doing the database.

It seems like a strange thing to not get user input on. I would want input on that. It seems like if someone was going to be doing that sort of thing on a database that I was working on, I would be like, hey, I have input on when I would like this to happen.

If you see SB who is active running, stop doing what you’re doing. Something bad is happening. It could be, like, I still think it’s going to be like a system database maybe.

Or the column level encryption thing that you said you’re using. Who knows? All sorts of fun stuff going on there. All sorts of fun stuff going on up in the cloud.

All sorts of fun stuff. Does anyone else have a SQL Server question? Come on.

There are a billion of you out there. One billion. You’re not spamming chat. There’s no spam, please. Ask all the questions you want.

There is nothing else in here. He said I have a stinky update statement which has a function being used. For example, update my table set my field equals write my field 1.6.

My table has around 10 million records in it. I know the best thing here would be to remove the function entirely, but I can’t do that. Is there any way I can prove this?

Only way I have been able to improve this is to do something like set my field equals write. Yeah.

So the function, built-in functions. Let me be very clear about this. Built-in functions like write, left, substring, date, add, date, time. And that situation don’t have the same kind of overhead that, like a user-defined function of this scalar or multi-statement like the at sign table variable returning type would.

Those functions don’t really trouble queries too much unless you put them in a where clause. Now, granted, like how you’re doing it in the where clause might be helpful in that even though you have to scan all 10 million rows, you probably rule some of those 10 million rows out.

So what I would do is rather than update your table with that, I would add a computed column. Not persisted, just a computed column. So you could add, you know, it’s an alter table, my table.

Add my field computed as case when my field 2 is not equal to write my field 1, 6, then write my field 1, 6. And that would be instant, as long as you don’t persist it, that would be instantaneous.

And then you could index that column. You could do all sorts of fun stuff to that column. You wouldn’t have to go and update the entire table.

You would just have this virtual column sitting on your table that has that on there. No, that would, no, no. Those, the built-in functions are CLR.

They’re CLR. Let’s just call them CLR-ish. They’re behind the scenes. They are C Sharp. They take advantage of .NET stuff, and they don’t, they don’t, they don’t force anything to run serially. So, no.

You don’t have that problem there. The only thing that forces, I mean, there are a few things that force serialization. Right now, the most common is scalar user-defined functions. Modifying table variables in 99% of circumstances.

Global aggregates. Certain system views. The recursive part of a recursive CTE. Gosh, a whole bunch of stuff.

Top, when it’s outside of a cross-supply. Justin says, how do you pronounce S-A-R-G ability? How do I pronounce that word?

Sargability. Search argument. Sargability. If anyone says Sargability, ask them if they pronounce argument, argument. Or if they, I guess that’s it.

And then if they want to argue with you about it, you can say, well, that’s not how you pronounce argue. Ijit. That’s my advice.

You have heard S-Argability? The hell said that? You have my permission to throw eggs at whoever pronounces it that way. How do you pronounce G-I-F?

That depends on where I am in the world. In France, it is les GIFs. In certain parts of rural America, it is GIF.

In other parts, depending on local colloquialisms, it could be GIF or GIF or GIF. It kind of depends on where you are. Local factors apply.

Okay. Local factors apply to that. There’s no, I mean, there might be. There might be an intended way to pronounce that.

But, you know, all sorts of things happen when words are culturally embraced by people who speak differently, speak different languages. So, really, you know, hard Gs and soft Gs don’t exist in every single tongue. Some, I’ve heard that there are some languages out there that don’t have the letter G in them at all.

They’ve skipped over it entirely. So, how do you pronounce that? How do you pronounce that word if you don’t, if you haven’t invented the letter G? It’s a tough one.

It’s a tough one. You know, most importantly, there is an I in GIF, and I decide how I’m going to say that one. Greek have no letter G.

Isn’t that ironic? So, they’re just reeks. That’s weird, because I know several Greek people.

Well, I guess, I guess, I mean, they’re named like Giorgio or something. Or George, George, George something, Georgious, Giorgio, Giorgio, or Georgie, something like that. I don’t know.

I’ve given up on learning new languages. I’m just no good at it. I can’t even learn JavaScript. Talk about how tough life is.

But in English, G is not associated with a single sound. No, G is associated with many sounds, including sounds that aren’t like, you know, G alone, like ing. Like, there’s no G sound, like ing, ing, ing.

Like, talking, texting, walking. There’s a G in there. Josh has announced his presence, thank goodness.

I was wondering how I was going to develop an ulcer without you. Now that you’re here, you better ask a good question. Which you won’t, because you’re lazy.

You didn’t come prepared. Yes, today’s episode is brought to you by the letter G. Like, G, I wish I was sitting somewhere drinking.

Gosh darn it. I want to go drink. Golly and gosh. Glass of wine sure would be great.

Grandma’s gin, Ginny Gums, Gristle Grimly. Gee, I’m still at work. It’s 1230 here.

Oh, it’s like 530 there, I think. Unless you have a weird daylight savings time thing going on. It’s 530 there, I think. I think UK is five hours ahead.

France is six. Wilson says, I saw this on Reddit today. You have any tools you use? What?

Tools. I got a whole box of tools behind those nagels that someday I’m going to use to hang up those nagels. But I have to buy a piece of furniture for over here first. My office underwent a half-assed redesign before I went on vacation for a month.

I got a new standing desk. And I threw up my old desk, which was like an L shape. And it had a bunch of drawers and storage in it.

So now I have my old standing desk riser put up to maximum height. And I’m using that as ghetto shelving until I decide on what kind of piece of furniture I’m going to use over here to put my stuff on. And then when I get that, I can make more permanent choices about where Ren and Stimpy and the nagels will go.

And that’s how dull my life is. I don’t know. It’s awful.

Josh asks, if a query’s duration and CPU usage increases according to Query Store, there’s your first problem. Never trust a query store. But nothing else does.

With the same plan, same logical reads, dop, et cetera, what could that mean? Well, if it’s the same reads, that rules a lot of things out like index fragmentation. And if duration and CPU are both going up, then that rules out external forces like blocking, in which case duration would increase and CPU would stay the same or maybe even go down.

Let’s see. What could cause that? Maybe.

Well, it’s the same plan. Well, actually, that could make sense. What if, I mean, you could be, what if you’re just dealing with more data? Or, I guess what I might be interested in is, if it’s the same plan, are you hitting parameter sniffing?

Remember that one? Remember parameter sniffing? That thing that you learned about in high school?

That was glue sniffing. Yeah. All right. Well, I mean, it sounds like it could be parameter sniffing. It could be. I don’t really know what else to make of that.

If it’s the same plan, and reads aren’t, oh, well, reads aren’t going up, so parameter sniffing would probably rule that out. Yeah. It’s a VM.

Oh, boy. Okay. So, if you’re on SQL Server 2017, if you’re on SQL Server 2017 and using Query Store, you might want to join off to that aggregate wait stats view, like Query Store wait stats, to see if there are different waits involved for different iterations of this query. That’s what I’d point to.

That’s what I’d point to. But you’re probably on 2016, and I’m going to be disappointed in you. Oh, good idea. I finally had one of those.

I’m so happy when I have a good idea. Happens once a year. Once a year. My good idea for last year was, well, it’s still this year. Crap.

I guess I have two good ideas this year. Actually, three. One is, I didn’t get a real job. Two is, I had temporary tattoos made for swag. And three is, check the wait stats.

It’s funny, because I hate wait stats. Josh wonders aloud if SOS scheduler yield, like CPU contention or an oversubscribed VM, would be included in CPU time. Maybe.

Maybe. I would also look at what that query is doing, because, well, it might need to read like a fairly set amount of data.

I don’t know. Is it? I’m always curious when, like, a query is, like, really CPU intensive without being really read intensive. Like, what are you up to in there?

Like, all your data is in memory if you’re not doing, like, a lot of reads. Grumbling monster behind me. All your data is in memory.

If you’re just, like, purely pushing CPU, that’s one thing. I wonder if this query is parallel or serial, if the plan is parallel or serial. And I would wonder further if there are other issues involved.

I don’t know. We’ll have to wait for this. This sounds like a good question for dba.stackexchange.com, a site you may or may not have heard of, for data professionals.

A parallel plan. Let’s see. It’s from an SE question.

You thief! You liar! Come here with bootleg questions. I had to shoot you. Shoot you like the scoundrel you are. It’s a parallel plan.

Well, if it’s someone else’s question, I’m going to assume you don’t have access to run the query and see if there is perhaps some issues with the parallelisms of the query. Like, perhaps some spillage or some skewedness across different things. Because that would certainly explain why CPU and duration would go up without a meaningful increase in reads.

I would want to know. So here’s what I would, here’s where I would dig in. Right?

Reads are the same. Yeah, reads are the same. Same plan. Same dot. Duration and CPU are going up.

Tell me if that query is doing any writes. Tell me if that query is spilling or spooling or doing something else. Tell me if that, like, you know, there’s no way to see it now.

But now it’s like all these, all these things that, like, queries that when selects cause rights, that’s, that’s in my head now. And I’m thinking, like, well, I don’t know, like, like, are you updating stats behind the scenes sometimes? Are you, are you doing some other labor intensive tasks that wouldn’t show up traditionally with a query?

Right? Wouldn’t, wouldn’t, wouldn’t impact query runtime. Wouldn’t, like, show up as, like, a query weight.

It would just be, we did, we had more CPU associated with us behind the scenes. But, you know, we don’t have a good way of finding that out. So I would want to know if that query is performing writes of any kind.

That’s, that would be my next thing. I.O. completion weights would be something to look into. Because that’s usually our sleep task.

So I.O. completion would be, like, sort spills. Sleep, sleep task would be, like, hash spills. There’s no way to tell behind the scenes if it’s updating stats or something when the query runs. But, you know, depending on what goes on there, that could be, could be a drag.

Be quite a drag. Ha ha ha ha ha ha ha. So, yeah. That’s what I would, that’s, that would be, that would be my, the next place that I went to look at. My troubleshooting repertoire.

Like, what’s going on behind here? Oh, man. That was exhausting. It is a select into.

Okay. Well. We’ve, we’ve, we’ve certainly started to piece together slowly but surely. What, what is, what might be going on with this query?

So now we have a select into. Are we selecting into a user database or into a temp table? Do we have additional contention in this user, user database or in this temp table for some reason? Do we have anything that might be blocking writes to this table?

I know it’s a select into. But if you have snapshots occurring, like snapshot backups occurring, they’re quiescing activity. Well, because no, it’s, no, they’ll be blocking.

Never mind. We’re back to the CPU and duration going up and nothing else. Arr. Just trying to crowdsource my answer so I can get more rep than you. Ah, just go ahead.

I’ll, if I could bounty all my rep away and live like a stack exchange hermit, I would. But I do not have the patience to give my rep away like 500 points at a time. One day at a time.

I don’t think you, like you can’t have multiple bounties open at once. Forrest brings up an interesting point. If there’s only a small amount of space available in the database, does SQL Server have to spend more time writing disjoint extents?

How about this one? Does SQL, if SQL Server has to grow when, that has to grow the database and you do the select into? That’s certainly something that I don’t know that, like, I don’t know if that would count towards query CPU and duration.

Like, definitely query duration. I’m not sure if that would count towards query CPU. But if we had to grow the database and, and growths were slow in the database, like, let’s say, you know, a database, database was good.

Like, instant file initialization wasn’t turned on or, so instant file wasn’t turned on, you’re expanding the data file behind the scenes. That might be something. Another thing is, if the log file has to grow, that’s, I mean, instant file initialization never helps that.

So, if behind the scenes, we’re having to grow the transaction log, that could, that could certainly add. And, like, again, like, the part that I’m not sure on is if that would count towards query runtime. I’ve never cared enough to figure that out.

Maybe, maybe I do now. Or maybe that would make a good blog post for someone with a burning question on their mind. I don’t know that it’s quite burning for me yet.

What is burning is how hungry I am. That I’ve been talking for 40 minutes. 10 minutes longer than my usual webcast length. And I’m going to go eat now.

So, thank you for hanging out. I hope you had a time good with your face parts. Bye. Bye.

Bye.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I dive into the world of SQL Server query plans and execution, addressing some common questions and misconceptions head-on. Starting off with a bit of frustration towards YouTube’s tendency to mess up my recordings, I share how important it is to understand the nuances between estimated and actual plans. I explain that while there’s technically only one plan, the pre-execution show plan (the estimated plan) and the post-execution plan (which includes actual metrics) are distinct entities with their own unique characteristics. This discussion leads into a detailed exploration of how many indexes might be too many, covering factors like locking, blocking, memory usage, and workload patterns. I also touch on the complexities introduced by features such as Read Committed Snapshot Isolation (RCSI), offering practical advice for those considering its implementation in their databases. Overall, this video aims to provide a clearer understanding of SQL Server’s query optimization process and the considerations involved in database design and tuning.

Full Transcript

All right. Try that again. The do-over of all do-overs. The grand do-over. I like when audio works. Audio should be better now. Should be. YouTube does awful things to me. Every time, every time I do this, every time. I hate you, YouTube. I hate you, YouTube. You’re the worst. The pits. Gigantic, awful. I wish this was something stronger. Canada Dry Sparkling Seltzer Water.

All right. Who has questions? There are like a billion people here. Someone has to have a question about SQL Server. Someone. Someone out there.

Must have a question about SQL Server. Otherwise, why would you show up? What, what good reason is there to show up and watch me do nothing? Play with scissors? You just start cutting my hair randomly.

You don’t want to do that. No one likes that. See the dancing. It’s always moving. Just do what I want. When you dance, Kenneth. You see anyone saying, hey, Kenneth, good job dancing.

Kenneth, dance for me. No. Did I see the discussion yesterday about actual first estimated plants? Yes, I did. And it is the same thing that I’ve been saying since the dawn of time.

That when you talk about an actual plan, it’s just the plan that has the actual metrics in it. There’s no. Well, I won’t say there’s no functional difference.

But that’s, that’s where things get tricky. That’s where things get a little bit awkward when you say that there’s, there’s no difference. Because when you get an estimated plan, there are things that don’t happen. That happen in the actual plan.

Or what we should start calling them are the pre-execution query plan and the post-execution show plan. There are all sorts of post-optimization rewrites that may end up in the query plan. All sorts of things that happen post-optimization.

If you look at an extended events. If you ever look at extended events there, when you look under, oh gosh, what’s it called? So actually this brings up an interesting thing. So I’m going to get to everyone’s questions, but I want to share this because it’s funny.

If you use SSMS 18 and you have it crash because you use extended events or like you open up the extended events thing. If you do new session wizard instead of new session, it doesn’t crash, which is amazing to me. Anyway, I’m going to just do a couple of things here because I want to talk about how many different events there are for show plan.

There are four. Actually, let me make sure that I have the debug thing opened up too. Okay, there’s four altogether.

There’s post-compilation show plan. There’s post-execution show plan. There’s pre-execution show plan. In query store generate show plan failure. Let’s leave the query store one out of this. There are three show plan events. And extended events that you can use to capture execution plans.

The pre-execution show plan is, you know, exactly what it sounds like. The query hasn’t been executed yet, but it has a query plan. The post-compilation show plan is after SQL Server says, okay, I got a query here. I’m going to, this is, I’m going to plan.

And then you have the post-execution plan, which may contain rewrites that weren’t, stuff like bitmaps and other things that weren’t available or that weren’t explored yet when you had the pre-execution show plan or just the post-compilation show plan. The post-execution show plan is also going to have the actual stuff in it. So there’s all sorts of, I mean, while there is functionally one plan, you might see different things in the post-execution show plan than just the actual metrics.

You know, like, like query plans now get all sorts of extra stuff in them, right? They got wait stats, they get operator times, they get all sorts of cool stuff. And you can only see that in the actual, in the actual plan.

Let’s call it the post-execution plan. So you can only see it in the post-execution plan. But there are also optimizer rewrites that might show up in the post-execution show plan that would not be in the pre-execution plan. There are decisions that SQL Server makes that might show up in there that wouldn’t be in the pre-execution plan.

So I think for the for the sake of all of sanity, there, the way that we should really refer to query plans are the pre-execution show plan, right, which is like estimated pen like control L or whatever button you hit up in management studio and then the post-execution plan, which contains actual metrics about things. So there is one query plan, but there are two versions of the plan. There is the pre-execution show plan, the post-execution show plan.

And I’m right about that. You can tell everyone on Twitter Erik Darling’s right about that. Don’t listen to anyone else. Anyway, we have other questions now. Now that I’ve been talking for how long is it that 20, 30 minutes, half hour, 45 minutes.

How long did I talk about? That was a long talk. That was a long, long talk. I just never talked about anything that long. Sammy says, how many indexes is too many? I don’t know. I don’t know. You tell me. How many indexes do you have?

And are you having problems with those indexes? Too many? Okay. So let’s see. What things that you look at when you want to find, do I have too many indexes? What happened in my life that I have so many indexes? What went on that caused so many indexes to show up and what am I seeing now? Great questions.

So if you have too many indexes, you will see more locking because you have more objects to lock. You will see more blocking because more things are getting locked. Unless you have magical settings turned on or you use no lock everywhere. But then writers will still block each other.

So you might see more of that. You might see worse use of memory. You might see, you know, that metric that everyone poops their pants about. You might see PLE get really low because all of a sudden you need to read a whole bunch more stuff into memory.

When you modify it, you might see more, more indexes need to end up. Come on into memory. We’ve got to change you. You got pages. You got to write on those pages. Let’s get into memory. You might see PLE drop. Oh boy. You might see increased page IO latch SH if you’re needing to go out to disk to get more indexes.

So it’s like saying, it’s like asking someone, well, how many calories is eating at maintenance for you? That’s going to depend on a heck of a lot of stuff, right? Like when you talk about eating at maintenance, right? You talk about like calories in versus calories out. So clearly I specialize in calories in, but if you talk about eating at maintenance, like how many calories, how many indexes that can I have?

How many calories can I have? Well, it depends. How sedentary are you? How much time do you spend sitting on your butt? How much time do you spend up being active? How many times, how much time do you spend doing stuff at the gym, going for walks, swimming, riding a bike, thinking real hard, cleaning?

Oh man, it was funny when I first met my wife, she was like, you know, if you clean the house, you burn like 200 calories. Yeah. Okay. Your cardio is made. I will just make messes for the rest of your life. You will be skinny.

But yeah, it’s like, like what is like, so how do you eat at maintenance? Well, you have to figure out how active you are, how inactive you are. If you have a table with a very, very low write profile, right? A table just doesn’t take that many writes for some reason.

Like, you know, you load data in like once a night or something, and then you read data out, it’s going to matter, right? Like, write patterns matter for how many indexes you can have. That and like settings like RCSI, which we have a question about, I promise you I will get to.

You know, if you’re using no lock-ins, you can have way more indexes because you don’t have to worry about locking. But you know, you know, there are other factors involved. How much memory do you have?

Oh, there’s lots of stuff, right? There’s lots of stuff to think about. There’s no such thing as like, how many indexes is too many for everyone or anyone? Like how many calories can I eat? Because you have to adjust that based on what you do, right? It’s not just make a Blakins statement about that. I hate people who make, I hate everyone who makes blanket statements.

You can quote me on that. I hate everyone who makes blanket statements. Beat that. But yeah, so you know, it really depends on your, you know, starting from the outside and working in. If you have an availability group or if you have, you know, mirroring because you’re still cool or if you have log shipping, you know, then that’ll affect how may affect how many indexes you have because you have to start sending those indexes to other places.

If you have a crappy San, I don’t just mean disks. I mean the whole storage area network, you might be able to have fewer indexes because you might be spending a lot of time going out to disk and to read those indexes in. You might cause a lot of contention on those shared resources that, that exist between your server and the disks and the, and the storage area network.

If you have a lot of memory that might not matter. If you have way more memory than data, which is, which I’m sure is all of you. You’re all, you all have a terabyte of memory and like a hundred gigs of data.

You know, it’s, that’s going to change things, right? You can have more indexes because you don’t have to worry about that stuff. If you have a high right workload, you can have fewer indexes. I don’t know. There’s a lot of stuff, a lot of stuff. How many indexes is too many depends on you and your hardware and your choice of H a technology, H a D R technology.

Lots of things go into that equation. Yeah. Figure it out though. Look at your weight stats. Look at your locking, look at your blocking, look at your workload. Look at, uh, you know, your servers error logs.

See if you have a lot of see if the server is, you know, going going crazy with like 15 second IO warnings or flush cash or like saturation messages. That’s what I would do. Anyway. Kenneth says I found a property that tells you if the plan came from the cash or not.

Yeah, that’s a little wonky though. I wouldn’t always rely on that. I’ve seen cases where like I’m using a recompile hint and it’s telling me that the plan came from the cash. So I would be careful with that one. Uh, Kapil says I’ve been in this heated debate with developers to enable RCS in this database where there are about a thousand of blocking and deadlock throughout the day. We are on default and I am proposing to enable RCS and test it out from temp TB.

I am good. What are the things that should be taken care of? And what are the caveats will enable enabling RCS? Well, uh, excuse me, the revenge of the seltzer. Um, so here’s, here’s the thing. I generally love RCS.

I think it’s wonderful, but. And here’s here. There are a few butts with it. Well, not big butts, medium sized butts like 90s, like 90s butts, not 80s butts. So the thing with RCS, I of course, is, you know, you say you’re good from temp TB.

So I’m going to assume that you have multiple temp TB files. If you’re on a version prior to 2016, you probably have trace flags one, one, one, seven and one, one, one, eight enabled. If you’re on a newer version, 2016 and up, those are the default behavior. So you don’t have to worry about it anymore.

Uh, so. What I would start being concerned about, um, a, if you have any queries that depend on locking and blocking for correctness, like if you do any queuing, like if you say I need to, you know, um. What’s the, what’s the classic analogy?

I need to assign tickets to whoever. Uh, doesn’t have a ticket available. RCS. I can mess with that because you might be reading version of rows where someone, you know, uh, already has a ticket, but the, that hasn’t like fully gone through yet or something. And you might like double ticket someone. So RCS can affect query correctness where you depend on blocking.

The other thing that you have to start worrying about is long running transactions. So the version store cleans up in different ways, depending on if you have RCS or snapshot enabled. So long running transactions affect how much version store you’re taking out in different ways.

But you need to start being more wary of long running transactions. You also need to start being more concerned about, um, well, gosh, how many indexes you have, because the more indexes you, you need to, uh, modify the more stuff will end up in the version store. You also need to worry about the size of your transactions again, going back to what we were talking about for indexes.

If you have, if you are loading or modifying lots and lots of rows, your version store is going to get lots and lots and lots of big. So you need to be a little bit careful there and you need to, uh, start batching your modifications in smart ways. Like say only update, like, you know, a hundred thousand rows at a time.

So you don’t blow out your version store and therefore tempt. So there’s lots of stuff. Lots of stuff. Um, but there, you know, as far as like the initial set of things, I would, you know, a pay attention to queries that use cues, right? Let’s say like, I need to do things in a certain order and I need locking to do that.

So the other thing is that our CSI isn’t going to necessarily help with deadlocks because deadlocks are primarily, um, primarily. I’m going to say primarily because it’s not a hundred percent. Again, I hate people.

I hate everyone who makes blanket statements, but deadlocks are primarily, uh, writer on writer contention and our CSI is not going to help that. It will significantly help readers and writers get along better. Snapshot isolation you can use to, um, help writers not conflict, but that gets tough. That gets difficult because then you have to start handling exceptions where, uh, like a transaction tries to run and update a role that’s not there anymore.

So, bye. So you need to start handling that. Um, let’s see. Let’s scan down the list here. V says back in the day when you were learning to tune queries, did you ever hit major roadblocks in terms of progress? I’m interested to know what if so?

Yeah. You know, um, of course. Yeah. You always, there’s always going to be something, right? Whether it’s like, you know, you are in a position where, you know, you really want to change an index, but you can’t change the index. You’re the one adding index.

You can’t add an index. You really want to do something and you, for some reason, can’t do it, right? Like, I hit that all the time when I work with people who are like, we have entity framework and I’m like, great. And so, development time must be really fast. Great.

Because you can’t really do a lot with those queries. And any framework calls off and writes whatever query it wants. So, you know, it’s nice that now you can inject query hints, which is wonderful. But, you know, with EF, it’s a lot of like, you know, trying to like force plans, either plan guides or query store if someone has that turned on. That’s always a tough one.

You know, and then stuff where, you know, you see a bunch of anti patterns, right? And you’re like, well, these are like, you know, I’m going to like step through my playbook of stuff I know can help queries. The first thing I’m going to do is I’m going to ditch these anti patterns and I’m going to make things better by reversing those.

And then, holy crap, like you make things worse. Like there have been times I’m like tuning query. I’m like, ah, local variables, scale our functions. Now you’re doing all this stuff wrong.

This is all messed up. And I’ll like, I’ll like start plucking these things out one by one. I’m like, why is the query taking longer? Why is this so much lower? What was happening before? Like, what, like, how did I make things worse by taking out the things that everyone says are bad? And, you know, it’s because again, people make these blanket statements and they’re not going to be wrong.

They’re often bizarre. Bizarre. So, you know, and it’s always frustrating too when, you know, you, you invest a lot of time learning about something and learning the best ways to go about trying to tune things. And you start making these changes that, you know, have helped like lots of queries in the past that you’ve used and the steadfast, loyal query tuning tricks that like worked and done stuff.

And then you like, you start to like, this does nothing is helping. Nothing is changing this query. And that’s when, you know, you do have to, you know, sort of start, you do have to reexamine your, your, your playbook at that point and say, okay, what am I doing wrong?

What can I do differently here? And, you know, that’s also when the investigation kind of has to go beyond, okay, I’m changing things about the query and I’m changing things about the indexes, but I am not getting the expected results. And that’s when you kind of have to go a level deeper and you have to start figuring out, okay, well, you know, I’ve got, I’ve got these changes that I’m making that should be making things better.

What’s wrong now? And you kind of have to start like, okay, well, like, you know, if I’m running this query, what else is going on in the server? Like, what is the serve?

What’s what feedback is a server giving me about what’s happening here? Like, am I, am I, you know, changing things, but am I using more CPU or less CPU or doing more writes or more reads or less reads? Am I being blocked? Is like, there’s just some fundamental issue with the server where it’s like, just like a, like a thing that I’m never going to be able to vault over. Right.

Like, you know, I think I blogged recently about when I was working with a client and, you know, like I would, like I’m, I’m, I’m up early. I’m always up or I’m, I’m, I essentially never sleep. I’m like four hours a night, something like that. But, you know, I’m up, I’m up early. I’m like, you know, like I like to get in and do stuff.

I like to, you know, go to the gym later. I look to do all my work early so I can get out and, you know, like I’m tuning this query and like, I’m making okay progress, but like it’s like six in the morning. I’m like, yeah, I’m like, got this thing down from like, I don’t know, 10 seconds to two seconds or something. And then like, is the morning war on?

I was like, I’m like, I want to show this to people. And I’m like, like seven o’clock. It took seven seconds again. And then like eight, nine o’clock. It was like 20 seconds, 10 or 11 o’clock. It was like 30 seconds. Like. How did this get slower?

And like I wasn’t being blocked by anything because I was in my own separate database. But this server was just so hammered with other queries. I was hitting like thread pool. I was hitting like resource semaphore weights. I was, I was getting knocked around by other act. There was just like things about the server that meant this query was never going to be reliably fast.

I could get it to be faster. And I said a vacuum like when there was nothing else on the server. And maybe if every other, like if every other query running on the server got tuned, this thing would be reliably fast. Or like if every other instance of this query were tuned the way I had it tuned, like they would all like take up fewer resources.

So I wouldn’t be as blocked out as I was. But the end of the day was like baffling. And, you know, sometimes, sometimes you hit roadblocks that aren’t your fault. So there’s lots of stuff in there. So, yeah, I don’t know.

There’s that. Let’s see. Sammy says great analog. Thank you. I try. I try my best to be an eight track man. Let’s see. Lee says personally, I would watch out for the version store size and having our CSI turned on.

Yes. Good job, Lee. I think I think that’s a new picture. I like it. Nice sky behind you. Sam says if they’re literally duplicate indexes, is there any overhead dropping a non clustered if it’s a primary key? I don’t understand that question.

If it’s an exact. So generally, when you have a primary key, it’s also the clustered index. And if you have a nonclustered index on top of just that primary key column, it can be helpful because then you can use that that narrow index to look up the same values that you would in the primary key and SQL Server knowing that is the primary key knows that it’s unique. So it can do all sorts of fun stuff there.

Of course, you know, there’s going to be overhead, but most of the overhead I find in indexes is not with the insert pattern. Most rows get inserted like OLTP wise, like like one row at a time or maybe like five or 10 rows at a time if you’re updating like an orders table with like the items in the order or something. But so like most insert patterns are like, you know, customer comes in and does something like you might like audit it or, you know, they might my new customer, right?

You typically had one new cut, you know, like 10 new customers that get loaded or like a million new customers to get loaded in at once unless you do something weird in the application. But anyway, you know, you know, it can sometimes having a narrower do like slightly duplicative index is a good thing because, you know, if your primary key is a clustered index, you can get pretty bogged down. If you’re just constantly leaning on the clustered index for things.

So, you know, well, it can be helpful and totally be helpful. I think the classic example is, you know, looking at like, say, like only have like a clustered index on a table and say, like select count from table, right? And look at how many like set statistics time and IO on.

Look at how many reads you do. Look at how much CPU you use. Then create a nonclustered index on the clustered index key column or columns or whatever, and then do the same count. So it was ever can use a smaller index, right? So like the smaller indexes are like, even if they’re duplicative of the bigger indexes, I’m more concerned with a bunch of nonclustered indexes that are duplicative of each other than I am a nonclustered index. That’s slightly do that slightly duplicative of the clustered index just because I don’t like leaning on clustered indexes for stuff.

They’re big, right? They’re like the table. They’re like, you know, big strings in there or XML or JSON or bar by big strings. You have to read all that stuff, you know, potentially.

SQL Server is pretty good about not reading lob data when it doesn’t have to. But if you have like regular string data in there that’s like not max or 4,000, 8,000, not on overflow pages, then yeah, you know, it’s like I’m totally cool with having narrower versions of indexes for SQL Server to use and not and have like a smaller memory footprint, hopefully. And, you know, be able to read faster and all that other good stuff, right?

Like density is important to you know how many how many rows you can fit on pages is also pretty important. So I like to, you know, I like to have my indexes be as dense as possible. I can I can read it.

I can read them quickly. Let’s see. But Bill says exactly. I have those with separate 10 DB drives on SSDs. Kerberos. What about I don’t do that stuff. Don’t ask me about Kerberos. Let’s see.

Cabell says I have max four to five. I’m gonna assume indexes per table. This DB is 10 terabytes with partitioning enabled. Oh, okay. All right. 10 terabytes is like, you know, pretty big. I hope you’re not storing a bunch of like PDFs and stuff in there. That’s always a favorite of mine.

Like we’re like, we have a 40 terabyte database. It’s huge. You can’t do anything with it. And I’m like, well, what’s in there? And they’re like PDFs images. I’m like, well, there you go. Good news. I have excellent consulting advice for you. I have unbeatable consulting advice about that.

Don’t do it. Done. Unbeatable. Don’t do that. Don’t do it. Don’t stop. But we need to edit PDS and SQL. I’m like, no, you goddamn.

People have people want to do funny things. And like you and like when, when you’re first learning about C, you’re like, oh, that’s a neat trick. I remember, you know, like when I, whenever I, it seemed like when I was first learning stuff, whenever I like asked the internet a question about SQL Server, I would end up on SQL Server Central. And you would find people write these articles like generating barcodes and like QR codes and like, and like ran and like whatever random numbers, editing PDFs and HTML.

And you’re like, wow, you spent a lot of time doing that. And then like, you know, I just, I just, the more you learn about SQL, you realize like you spent a lot of time on that bad idea. Like, wow, you, you really invested a lot of time in that bad idea.

That’s, that’s, that’s kind of sad. Someone write articles. It’s like, no, no, please don’t do that though. It’s nice that you figured out how, but please don’t.

Like what’s that? It’s that, that Jurassic Park thing spent so much time asking if you could, you didn’t bother if you asking if you should. Don’t come on. Let’s see.

Lee says, I would agree. We still have deadlocks when we have RCSI in all our instances. Yeah. It’s just one of those things you got to, I mean, if you have, I mean, if you truly have a lot of indefeatable deadlocks, your absolute best bet in the world is retry logic.

It like it, I would, I won’t say it’s hacky to do it in stored procedures. Like it’s not hacky. It’s just maybe not my favorite pattern.

I would much rather do it in the application and just like, like retry something a few times, like wait, like a hundred milliseconds and retry. Like, because then at least you can send something back to, you know, whoever is trying to do something. Like you can say, like, you know, like you can either say like update a screen that’s like, has like a progress bar on it or say retrying transaction or something like that.

So that, you know, they have some feedback. It’s not just like, wait, like let’s, let’s see deadlock monitors every five seconds. So let’s say it wakes up and it takes a couple of seconds to do something.

So let’s say waiting seven seconds and then just getting a, like a red blob. You’re like, wait a minute. What happened? And then like, you know, trying, I’m going to do something again. So I like app retry logic a lot. Deadlocks have a very specific error number.

So it’s pretty easy to capture. You can do it in store procedures too. And I’m fine with it. There is totally okay with me there. It’s I just like applic. I just like when I just making developers do stuff. I like making developers do work more than I like making SQL Server do work. Like go program something.

What do we pay you for? Let’s see. Bill says just customer data. And yeah, we’re designed for some of the tables, especially those data types. It’s just 24 seven and data keeps coming. Yeah, I hear that.

Um, uh, let’s see, let’s see what other, what do I have anything charming to say about that? Um, I think, you know, so if you can’t sell them on RCSI, if they’re like, we don’t want every single transaction using this, then there’s always snapshot isolation. So you can, you can sell them piecemeal on things, right?

So the nice thing about snapshot isolation is that you get all the benefits of RCSI, but you have to ask for it, right? So you have to say, please, SQL Server, may I have the snapshot isolation in SQL services? Yeah, no problem, pal.

I got you. So, you know, if you have like, if you have read queries that you know are long running, you can say, okay, from you know what, we’re going to turn on snapshot isolation. And we’re just going to try it with these queries first, we’re going to see how it goes, right? We’re, we’re just going to try it as toes in the water, flick it a little bit, see what’s going on in there, make sure there are no snakes or worms with teeth or evil fish or snapping turtles.

Amoeba, brain eating amoeba, make sure that we have nothing too crazy in there. And then, and then, you know, if, if you can sell them on, on the, like, like, say you have reporting queries or just like queries that do a lot of reads or for some reason, and those keep getting blocked. And snapshot isolation is a good way to introduce people to the wonders of optimistic isolation levels, because you can sell them on the big queries and then you can, you can say, okay, look, our CSI, I know it swings a big bat, right?

Just, that’s just right over the head. But, but, but snapshot isolation, you can, you can get in there and like really, like a, like a watchmaker, figure out which queries you want to apply it to, just use it for those. So I would, so maybe if you can’t sell them on our CSI, you can sell them on snapshot isolation.

You can save them on like the, the, the bit by bit thing. That would be, that would be my goal. I think that’s what I would go with. He says worms with teeth is code for no lock, right? You know, no lock just gets this bad rap.

I can’t figure it out. Just kidding. I would literally say no lock is just misunderstood, but man, it’s, I don’t know. The worst part about like anything to do with no lock is.

There’s no like just dead simple alternative to it. Because SQL Server by default is pessimistic. If SQL Server were optimistic by default, which it should be, which it is an Azure SQL DB.

And gosh, darn it. You wouldn’t have people making this mistake. And it sucks to have to like lecture grown grown ass people. You shouldn’t use no lock.

Here’s why. You shouldn’t do it. They’re like, but it made my life better. You’re like, yes, but you might have wrong data. And they’re like, where? I don’t know. How do you know?

That’s, that’s like, well, you could have incorrect data. You could have incorrect data. You could see incorrect data. It’s not a good idea. No lock doesn’t mean you’re not taking any locks. No lock means you’re not respecting other people’s locks. And so, you know, it’s misnamed is the first problem.

It’s misnamed. It should be with no care. Like, I don’t care what I get. Give me something.

I don’t care. With no care would be a much better name for no lock. Anyway, I’ve been going for over a half hour now. I’m going to hop on. Well, I have about 20 minutes to eat before I have another call. So I was on a call all morning and a call right before this, and I’m going to be on another call with the same headphones on.

My ears are going to start smelling like headphones. It’s going to be disgusting. Anyway, I’ll see you next week with my headphone ears. Anyway, thanks for coming. I hope you had fun and learn stuff, and I will see you next time. Goodbye.

Adios. Yeah. Bye.

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.

Live SQL Server Q&A!

ICYMI



Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I delve into a real-world scenario where I faced some unexpected challenges with my web hosting provider, GoDaddy, and the Office 365 email service. I share my experience of dealing with emails that consistently end up in junk folders despite repeated attempts to flag them as not junk, leading me to consider switching to G Suite. The discussion then shifts to a technical question from the community: how to evaluate whether a table with numerous indexes should be optimized or if the existing indexes are sufficient for the workload pattern. I walk through using SQL Server’s SP_BlitzIndex and SP_BlitzCache stored procedures to analyze index usage, focusing on read and write operations, and emphasize the importance of understanding the actual workload before making any changes.

Full Transcript

SQL Server, T-SQL, SSMS, query plans, and data. It’s been a bad week for me and Microsoft. Me and Microsoft have had some problems this week.

When I signed up for web hosting, I went through GoDaddy, largely because I had an account. There was no other real reason for it there. I had an account there. I had bought domains through there in the past.

And so I just went with it. I went crazy. I was like, I’m going to use you, GoDaddy. And I got my stuff through GoDaddy. And they provide you with email via Office 365. The problem I’ve been having with Office since I started using it is that the contact form on my website generates an email.

And the email is from the person who sends it. And the subject line is SQL Server Consulting Inquiry. Okay, pretty easy.

And for the last now nine months and three days, every email that comes in as a SQL Server Consulting Inquiry goes into junk email. I dutifully say not junk and I report it to Microsoft as not junk. I say this is not junk email.

This is how Erik Darling makes his money. This is how Erik Darling affords new Nagel prints when he wants them. There’s another one behind there. But every single one goes to junk despite me reporting it over and over again. And so I’m this close to moving to G Suite.

The only thing I have to figure out is how much of a pain in the butt it’s going to be to move to G Suite. And then if I can keep the rest of the Office products that I need because, you know, I just don’t want the email. But having like, like Word and PowerPoint and Excel and all that, all the other stuff that I use pretty frequently would be nice to have.

Ren and Stimpy is not new though. Ren and Stimpy has been in my life. Let’s see, it’s 2019 for almost five years.

Ren and Stimpy has been in my life. I bought Ren and Stimpy and Dune at the same time. Dune over there. Oh, yeah, that’s what that’s there. But this this past weekend I bought I bought some Nagels. They were they weren’t they weren’t expensive.

They’re not like real Nagels. They’re they’re just Nagel posters. They were like 100 bucks. So I was just happy to get some Nagels. I just have to put them up. It’s the other problem I have is finding time to put things up. Eventually, I’ll figure that out.

I also need to find time to shave. Art all seems to be from a distinct era. Ren and Stimpy was the 90s. Dune was the 80s. Nagel was the 80s. I love I love I love some 80s. I guess I guess is your point.

You’re right there if you’re if you’re trying to call me a fan of the 80s. I do not dispute that. Cannot dispute that. All right, so.

No one’s asking any questions, so I actually have a mailbag question. This week someone was kind enough whose name I won’t say on air out of respect for the living and the dead. And also out of respect for the fact that they probably don’t want that.

So I’ll just say we’ll just call them. See, I’ll check my notes. We will call them butt stuff. So my friend butt stuff has asked.

I’m looking at a table with 10 indexes. 10. 10 indexes. The DBA said he wasn’t worried about the cost of inserts, but I’m concerned. There seems to be overlap on the indexes.

An extra column here. Combineable includes there. The developers said they worked very hard on these indexes and aren’t changing any of them. How how do I go about proving or disproving that I should have these I should change make the index changes that I want. Hmm.

Hmm. Well, it’s a great great set of questions. And the first thing that I would the first thing I want to bring up is, so if you want, if you want to, if there’s a hill that you’re willing to die on, you have to be really, really sure that like there’s there’s a problem there in the first place. So.

I while back, I was in a similar situation where I was working with a client who had migrated their application from access. And when they did that, somehow, I don’t know what the process was exactly. I’m unclear on that because I’ve never migrated anything from access to SQL Server.

I have thankfully blissfully and any other kind where I have I’ve avoided that situation in my life. But when they did that, what they told me what happened is that SQL Server created all the tables. Or not all but many of the tables is the tables had clustered indexes that were like all of the columns in the table.

So you would have a column table with five or six columns in it. And SQL Server created a clustered index on all five or six. And I was like.

It’s the worst thing I’ve ever seen. Access sucks, man. So I I I I I I I I I I’m going to show these people how bad this is. And so I set up a test to do a bunch of single column or single row inserts into a similar table with a wide clustered index. And it turns out they didn’t make a difference for single row inserts.

It started to make a difference when I got up around like a million rows or 2 million rows or, you know, like larger inserts, but they weren’t doing inserts like that. So it was totally wasn’t applicable. In other words, I I got all riled up for nothing.

I was all I was all I I was like it was like index design crazy at that point in my life, I guess. And I was sitting there, man, I got to show these people what’s up. You know, really, really bury this one. And I was wrong internally.

I was wrong. So the first thing to do is understand your workload pattern. If you’re doing a bunch of single row inserts, probably not going to be the biggest deal in the world. Where it might start making a bigger deal is if you’re doing larger updates or deletes. So there are two stored procedures that are going to help you with this with this problem.

The first one is going to be SP Blitz index, which you can go to first, which I I made a code contribution to last last week weekend. Same with Blitz cache actually did did a few things on Blitz cache, but those are the two you’re going to use. You go to first responder kit dot org.

Oh, one word. Hold up a sign here. Let me let me let me let me make a sign for you. So that everyone understands where they’re going to go. And so you’re going to use SP Blitz index and first you’re going to run it against the database that you care about. And then you’re going to zoom in on the table that you care about.

So you can use the database name parameter. You can it’s really hard trying to write and talk at the same time independently. That’s interesting.

So you’re going to first run it against a database that you care about. Right, you’re going to look at the overall problems in the database that table might not be that big a deal. 10 indexes isn’t that crazy to me. And the second thing you’re going to look at second thing you’re going to do with SP Blitz index is use it to zoom in on a specific table. So if you feed it a database name and a table name, then you can zoom in and see if there’s any weird stuff with the with the table itself.

But what I would take a look at. When I would take a look at an SP Blitz index when you run it against the entire database one I would use I would use mode for so first I hope that’s not backwards for all of you first responder kit.org. So head over there and when you run it against Blitz index the entire database see if there are warnings for the table that you care about.

See if there are like big warnings like aggressive locking warnings are like like missing index warnings and like, you know, the duplicate and borderline duplicate index warnings. See if the stuff like that first. That’s the first thing that I would poke at.

And then and then after you run SP Blitz index and you look at that what I want you to do is run SP Blitz cache. What SP Blitz cache is the way you want to run SP Blitz cache is you want to run it. You want to run it.

Since you are your primary concern is with rights. Right with writing to that table you want to run it with a sort order rights or average rights AVG rights or the word average all spilled out. So it all depends on on how many fingers you have I think is how you end up spelling that I I don’t I have all of my fingers, but I don’t type with that many fingers. I think I type like this mostly or sometimes like this.

I very rarely get those involved. But yeah, so run it by rights first and see if there are any queries that are doing a lot of rights against this table that we care about. The second thing I want you to do is run it by reads or average reads.

So again AVG or average depending on how many fingers we’re going to get involved. And then I want you to look and see if there are any queries that are hitting that table and for doing a lot of reads. What this is going to tell you is two things one from Blitz index.

We’re going to see if we have any aggressive locking warnings. If we see aggressive locking warnings and I’m going to say, okay, there are queries that touch this table. That lock it up pretty good. Those are hopefully if your plan cash is like stable and solid and it’s not being cleared out constantly.

If it is, you’re going to have to run this. We’re going to have to run Blitz cash more regularly to maybe find these things, but you can run Blitz cash. You can see what’s doing a lot of rights. Hopefully the queries that we care about, they’re doing a lot of rights are going to be the ones that are hitting that table.

And then we can figure out, okay, maybe there’s a way that we can not do so many rights against that table and not lock it up so much. Ways to do that would be like batching, batching transactions. We’ll only hitting like, you know, 500, 1,000 rows at a time or something.

Right. If you are doing like big, big old whomping inserts into that table. And then the other thing we can look at is by reads. So, so if like, we’re not going to probably unless you’re doing big inserts. You’re not going to see anything that interesting.

Like there, what might pop up is updates because you could have to search a whole lot of a table to update very little of the table. So where that’s going to tie in is you might have some missing index requests against that table. And you might also have some, some update queries that are some delete queries.

If you, I mean, no, no, no, no, no one ever deletes anything. There’s no deletions in the database. We self delete maybe sometime once in a while. No one ever deletes anything, but yeah, that’s where you’re going to start to see if maybe there’s a query that’s looking for a lot of data and not finding it easily. It might be modifying data too.

It might be an update or a delete with the where clause. It might just be scanning a whole bunch of the table. So what I would, what I would do in that case is look first for like pathological symptoms that you have a case to prove, right? I wouldn’t go write my own tests, my own demonstrations.

I wouldn’t go writing my own sort of like test harness to try and prove or disprove when it’s bad. Cause it just might not be lined up with the reality of how that table gets used. I would want to like you, I would want to go into the plan cache.

I would want to go look at the metrics that SQL servers keeping about the indexes on that table. And I really want to start there and build a case with what’s, with what’s actually happening on the server rather than like, I think that might be bad. Let me, let me just go pick on these people for about, about these indexes that they worked so hard on.

I’m sorry. I didn’t mean to say that. This is a family friendly podcast or YouTube video, whatever. Anyway, let’s get back to the story. So yeah, you might be able to find some underlying pathologies with the borderline, borderline duplicate indexes and blitz index. And you might be able to find, you might be able to corroborate some of those pathologies with the information from blitz cache.

But, you know, make sure that, you know, you’re, you’re finding stuff that’s actually happening on the server, not just stuff that’s happening in your head when you look at that table. Because a lot of the times when, you know, as, as people who, who, who stare at SQL servers all day, we get very used to anti patterns or perceived anti patterns and chasing those things down. And quite often those anti patterns, those perceived anti patterns aren’t the, aren’t the biggest problem on a server.

And sometimes they’re not even a problem at all. Not every, I mean, anti patterns are like, you know, never a good thing to, you know, really like, like always chase down to the very end. You might find some and you might say, okay, well, this is, you know, something that generally you’d want to avoid, but it just might not be the problem that you’re having on that server. So I would, I would, I would, you know, I would take my time.

I would, I would not surface with more talk about changing things on this table until you have some evidence that there is a something bad going on. And B that, you know, it’s something you can correct by changing those indexes and C that, you know, it’s your index changes that don’t make the difference. Because it might not be an index consolidation thing.

You might need another index or two on that table. You, I know you have 10 and you really want to get rid of some and you want to combine some and I’m with that. I’m totally with that. But the problem might not be the indexes you have. The problem might be the indexes you don’t have. So anyway, that’s what I think about that.

I didn’t think of edit. I didn’t, I didn’t rehearse any of that. I just, I just did that off the top of my head. So you’re welcome. That is exactly the thought process I would have. And it would take me 15 minutes to get to that point with myself as well. I’m an incredibly unoptimized human being.

Forrest says, what do you think about EF queries? Well, Forrest, I think the same thing about EF queries that I think about presidents. As little as possible. Unless there’s something I have to think about them.

I don’t want to think about them. I don’t want to be faced with them. I don’t want to, I don’t want, I don’t want them in my head. I don’t want them burning away the precious few brain cells that I have left in here because I, it’s, it wouldn’t be good. Wouldn’t be good.

It’s scientifically proven that if you think about entity framework queries, or if you squat below parallel, that brain cells will shoot out of your ears, shoot directly out. And then it will explode. That’s exactly what it’ll do.

All right. So, do we have another question? Someone else want to talk? Someone else have a question about SQL Server? Or, I don’t know, anything else? Anyway, my friend butt stuff.

I hope that, I hope that answered your question. Forrest, who I will apparently be seeing in about a month for SQL Saturday. Crazy, right? Forrest is going to be in New York for SQL Saturday.

Joe Obish is going to be in New York for SQL Saturday. A lot of other very talented speakers are going to be in New York for SQL Saturday. Mr. Robish is having a pre-con for SQL Saturday. Very excited. His first one. Get him out of the gate with that.

Set him up good and proper as a valued pre-con presenter. Hopefully, anyway. As long as he doesn’t like turn into a fainting goat on stage. We’ll see. We’ll see about that. So this is where things get funny.

Outlook will let through stuff from Ninja Forms. Which I don’t, I got a newsletter from Ninja Forms. Which I’ve never asked for. I’ve never signed up for. I’ve never used.

But there we go. You know, there I go getting a newsletter from them. That doesn’t go into spam. What goes into spam? Consulting inquiries. Things that I need to get paid. Things that I need to pay rent for this room. Forrest asks, how often do you run across clients who would benefit from batch mode or columnstore?

Benefit from columnstore? I would say three or four times a year. I will get a client that is simply absorbing an insane amount of data and then aggregating it elsewhere.

I run across that three or four times a year. People who would benefit from batch mode generally. It’s not that they would benefit necessarily from batch mode processing.

Though some undoubtedly would. What a lot of people would benefit from is the stuff that’s currently hidden behind batch mode processing. So like the memory grant stuff. The adaptive join stuff.

You know, that stuff. The stuff that can sort of maybe kind of eventually help with parameter sniffing. So pretty often, pretty often it will see that, you know, I think everyone on earth with a SQL Server or the database in general probably is in some way dealing with. What do you call it?

What’s that word? What’s that word? Parameter sniffing. There we go. Slow in the application. Fast in SSMS. Someone has a deal with it. So yeah, you know, some of that stuff would help. Peter says, I tried to convince some NYC buddies to go to your columnstore thingy, but they all said columnstore is one of the things that works awesome. So no need to go.

Wow. You know, if they’re that good with columnstore, then they should be teaching the pre-con. So if columnstore is working fine for you, that’s great. I think if it’s the Joe’s pre-con is for people who want to really, really learn like like in depth about columnstore and batch mode processing.

I don’t necessarily know that there’s a good counter to that. If they’re not interested in learning more and they think their columnstore workload is running fine. That’s great.

I think what they would find is ways to make it better. I think they would find ways to improve upon what they’re already doing. Unless they’re unless their name is Nico. And then they maybe not maybe they might not learn anything if the name is Nico. You wrote a lot of their column stars.

Well, there you go. What problems could they possibly run into with you with you having been at the helm? I can’t can’t imagine. Can’t imagine why they’ve got to be so flawless. Why would they? Why would they ever need to learn anything further about columnstore? God bless.

God bless. Let’s see here. All right. Checking for some questions here. No questions there. No, that’s a thing. That’s another thing.

All right. Cool. Anyone else? Anyone else have a question? While I’m here staring at you blindly mindlessly getting bored getting lonely getting sad. Anyway.

All right. I’m going to get going then. Thank you for joining me. Thanks for hanging out. And I will see you next week. For a whole nother episode of this, whatever you want to call it. Marios.

Thanks for jumping up and standing over myrice. AsẸ. As I trulyolan can optimize your thanks to my heart and your song. Themetros are all about thesinoss launches remains your subescaytes.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I delve into a mix of personal reflections and technical discussions, weaving together various topics from database administration to scripting. Starting off on a somewhat chaotic note, I share the day’s peculiarities—working on my PowerShell skills and tuning queries while dealing with an unexpected cuticle issue that has become a daily ritual. The conversation quickly shifts to the diverse nature of DBA roles across different companies, highlighting how despite varied responsibilities, many challenges and experiences remain remarkably similar. Throughout the video, I also touch on ongoing projects like refining the BlitzScripts and exploring ideas for improving index management tools.

Full Transcript

I’m live. This is my second attempt at starting this because the first attempt went back to using the wrong microphone. Crazy, I know. Crazy, I know. So now, let’s see. Is anyone in here? No, no one in here. Good. I didn’t want to talk to anyone anyway. To be honest, he’s… Kidding. I love talking to people. I love talking to people. I love getting to know people, having their questions. I’m in deleting videos, maybe… Why won’t you let me delete you? There we go. Very confusing. Things around deleting videos on YouTube. So my prediction is no one’s going to show up. And my further prediction is that I’m going to talk about nothing for about 45 more seconds. Literally 45 seconds.

We’ll see, though. Who knows what will happen. Right now. We know what I should have done. I feel silly. For not doing this. When I had a bunch of stuff to do, I could have done that. Well, actually, I don’t know if I could have done that. Isn’t that… It’s depressing to know that I don’t even… I don’t think I could have done that. I…

I really… What I was thinking is, I mean, it would be cool if… Because I was… I’ve been working on the first responder kit again. Working on the first responder kit. A lot of fun. Again, getting back into the Blitz scripts. Because… Let’s face it. Writing a bunch of stuff like that from scratch would be goofy as hell.

Goofy. You know, in my head when I first was thinking about doing it, I was like, I have all these ideas that would tie all these disparate data points together. And I really want to code that. And then I’m like…

The reality of work set in. The reality of free time set in. And, you know, I just… I end up… You know, because I’m so comfortable with them, I end up using the Blitz scripts when I talk to my customers. So that’s fun.

I don’t know. It’s all right. It’s all right. So I’ve been working on those again. I added a couple things. Well, hopefully, as long as my pull requests are approved at some point. I…

I’ve added a couple things to BlitzCache. And I added… Well, I’m adding something now to BlitzIndex. It looks like it works. So I’m going to save this and create a pull request. I can’t show you because YouTube streaming sucks like that. But I promise you I’m doing it.

Live and in person while you watch. Let’s see. Joe has a question, though. Joe has an important question about partitioning. One of my favorite subjects. For partitioned indexes, does the field that is partitioned on need to be in the key value list? God, yes.

Like, I think that might be like an actual restriction. But on top of that, like, if you want partition elimination, if you want any of, like, the meager scraps of performance improvement that you might get from partitioning your indexes, it better be in there. Otherwise, you are screwed in ways which I cannot account for.

So, yes. Yes, it does. Definitely want that in there. Absolutely. Without it, who knows what will happen to you.

Be sucked into the cold, lifeless vortex of space. Blood cold boiled in your veins. You’ll be in good company, though. You’ll be with Elon Musk’s car guy. You’ll be with George Clooney space dust himself in that dumb movie.

Gravity. What was the other one? There was some other space movie. Steve Buscemi, maybe. Tim Robbins or someone just opened up their space mask and they go, squish themselves.

That’s how I want to go. Valiantly in space. Preferably shooting a laser. That’s my ideal. My ideal way to go. Yeah, buddy.

Yeah, buddy. All right. There are a handful of you here. I’m surprised. I was expecting no one to show up. Lucky me. But you have to ask questions if you want.

If you want this to go on for any amount of time. For all, what, 10 of you or something? Someone has to have a question about SQL Server. Otherwise, I’m going to go lay down on the floor and cry that I’m not on vacation anymore. Actually, I’ll probably just go to the gym.

I got to the gym three times in a month. And it was three days in a row when we were at a hotel that had one that I could do anything in that wasn’t cardio. The rest of the time, two weeks we were in an Airbnb, which had no gym.

And when I brought up the idea of getting a temporary gym membership, my wife scowled at me in a way that she has not scowled at me in a long time. Not since I think we were dating. And what else?

I don’t know. A couple other hotels here in had somehow worse hotel gyms than usual. And so I am a disgusting, soft mess right now. And I’ve been at the gym every single day this week just trying to get things to firm up a little bit in preparation for next week when I will resume regular lifting activities.

Regular. Regular. Hopefully putting another 200.

I want to get 250 overhead. I want to get 250 overhead press. As strict as possible. That’s what I’m going for. Because 225 ain’t good enough. 225 felt good until I realized it wasn’t 250.

And I don’t know. I guess 250 will feel good until I realize it’s not 300 or something. Idiot. Idiotic, right? 250 isn’t nuts.

250 is good. 250 is good because it’s more than I weigh. 225 is like borderline on that. Which is, you know, for guys about 5’10”.

It’s a healthy chunk of fat. See, Joe says, I have a table that is partitioned on field one. However, there is only one distinct value in field one. Seems worthless to have partitioning, right?

Yeah. That is the most useless partitioning. Because you have one partition. How many partitions? It was one. This is one single partition in that entire table. But on the other hand, I think it might be like just undoing partitioning on that table might not be worth the hassle.

I would probably just leave it alone. Like, is this an SAP database? This sounds like something that would happen in an SAP database.

So there’s like, I’ve worked with people who use SAP. And it’s funny. It’s an ERP, but not SAI.

Okay. So something like that. So it’s funny because SAP has like this software that they’re like, we’re going to be so flexible. You can use, it’s like multi-site or something like that. So like all the clustered indexes start with like this site key or something.

And then, but most people just have like a single site. So the clustered indexes are all just like the number one. That’s great.

Yeah. Multi-site. Exactly. I know. So let’s see here. Inful. I wonder what it is. Let’s see.

Marcy says, I heard you say you’re going to work on Blitz scripts. Can you please make Blitz index archive and delete unused indexes by table? So one of my grand plans for Blitz index has always been not like an automated version of that. Because like, I’m not willing to take the insurance risk of an automated version of that.

But like, right now it’s like a lot of analysis and not a lot of action. So what I wanted, like, what I wanted to do for a long time was like, give advice rather than just say, this is what’s up. Yeah.

Yeah. So what I wanted to do was like, have a mode where, you know, the advice turned into action. So like, if you had some unused indexes or some low, like low, not good use indexes, we would just say, here’s a drop script for that. Maybe you should think about dropping that.

Rather than like, just give you 20 columns of how poorly used they are. So stuff like that. And so like, unlike the real goal, like in my head, the ultimate goal would be to go through both indexes that you currently have and unused indexes and try to based on, well, for you, for indexes that exist. So based on reads, can start to consolidate overlapping indexes and for missing index requests based on impact and uses, consolidate indexes.

That’s going to be a little tougher. That’s going to be actually a lot tougher. But I would love to be able to put that in there.

Like in my, in my head, I think I have like good ideas to do that. But then, you know, the funny thing about my good ideas is that as soon as, as soon as I’m like, yep, here we go, it’s implemented. I’m like, oh, wait, that, that didn’t work.

There’s anyone who can do it. It’s me. I don’t know. I’m pretty sure there are lots of people who could do it. I can, I can think of so many people who I wish would do it instead. Boy, Rowdy says, what’s up, Eric?

What’s up, Rowdy? How are you? How are things in a sandwich biz? I kid. Rowdy is a semi-professional human being. Not quite as professional as Marcy. Marcy is extra professional.

Oh, boy. Everything’s boring today. It’s a weird day.

Like, it’s even like more weird than a usual Friday. I woke up late. I talked to Joe Sack for an hour about nothing. I don’t know. Worked on, worked on BlitzScripts.

Felt like I had a job again. Just kidding. Doesn’t feel that way at all. It was, so I, today I, you know, it was, it’s, it was the first time working on them as an outsider. So, I, I, I got all weird. It was all weird, like, not having, like, elevated access to stuff.

And I had, I actually had to read an old blog post of mine about how to work with other people’s GitHub repos. It’s like, oh, that’s how you do it. Oh, I messed that up. So, like, I had to, like, create my own fork and branch in my own fork and then create pull requests. And it was all goofy.

Like, ugh, how do, how do regular people do this? Just give me SA, Brent. Whatever, whatever it’s called on GitHub. I’m only going to go delete everything. Use those. Jerk. Anyway.

Marty says, working on some PowerShell, T-SQL bastardization scripts and hoping for Friday to go faster. You know, boy, that PowerShell. You love that PowerShell. I’ve never quite figured that PowerShell thing out. For me, you know what’s funny is for me, PowerShell was always a way to run SQL against some servers that, for some reason, I couldn’t use a, what do you call it?

Centralized server? That’s how long I’ve ignored DBS. Central management server.

There we go. Yeah. You know, I like PowerShell for some stuff. I like PowerShell for, like, administrative things. Like, for administering, like, Active Directory or Exchange or failover clusters or if you’re Paul White, managing availability groups with PowerShell is, like, a huge part of your job. And so, like, I think administratively, it’s really powerful and it’s got a lot going for it.

But the hot glue people use it as is sane sometimes. That’s where I learned it as a sysadmin. Now I have a hammer and everything is a nail.

I hear you. That’s how I feel about temp tables. No, I’m kidding. Ah, temp tables are great. I can’t tell you how many problems temp tables solve. Like, every day that I work with someone tuning queries, I feel like, don’t know, I’m picking my nails with a knife. I’m an idiot.

I’m probably going to cut a fingernail off my hand. But I’ve got this one weird corner cuticle situation. I don’t have dirty nails. I barely have any nails whatsoever. I have this one weird corner cuticle situation which is driving me nuts. So that’s what I’m doing surgery on while I talk. Because apparently it’s calming.

But, yeah, so every time I talk to someone, I was, like, working on, like, tuning queries. It’s, like, normal-looking query. You know, like, just, like, a select, pretty simple join, pretty simple where clause.

There’s, like, a bunch of, like, sub-queries in the select list. I’m, like, I’m, like, like, weird top one, like, go do some complicated count out and do stuff. I’m, like, this is confusing.

So I just, like, dump the regular select list into a temp table and then just do the sub-queries with the temp table. And I’m, like, oh, yeah, that fixed every single day. See, Matt says, isn’t it interesting that as DBAs we all do so many different things and that companies’ expectations that we support are so different from one shop to another?

Yeah, it’s, you know, I think it’s the beauty of the job is that so many people can call themselves DBAs and have very similar, you know, pains and war stories and, you know, very similar scars. But do very different jobs. Like, you know, I’m sure there’s been all sorts of, you know, like, if you take a production-type DBA who’s, you know, trying to, you know, fail over to DR or, like, you know, deal with an availability, like, patch an availability group or something crazy.

Like, they’ll have, like, very similar, it’s almost like how at one point in the world, different cultures all have, like, very similar stories or symbols or, like, you know, gods or something in their lore and, like, their beliefs and all that. Whereas, like, it doesn’t matter what angle you approach being a DBA from, you end up dealing with very similar issues. And it’s, like, like, you have management on one end and users on the other end and you in the middle and, like, developers annoying you.

Sorry, developers. You’re great. Thanks for keeping me in work. But, yeah, it’s just, like, it’s funny. And, you know, I’m, like, I’m a perf guy, but I end up talking to people about, you know, HA and DR stuff a lot.

And I sent out a tweet the other day about how, like, since I started my own thing, I’ve had four conversations with people about how you can’t have multiple writable, like, have, like, multiple primaries. They’re like two nodes that can accept rights in an availability group. Like, doesn’t it, isn’t it, is that not clear or not?

Like, like, they’re arguing with me. Like, I didn’t invent the technology and I didn’t write the documentation. Here’s the documentation. Here’s where it says you can’t do that. I’m like, no. But management wants it.

Like, talk to Microsoft. I actually had someone accuse me of, or not, well, not accuse me, but someone asked me who I worked for. Like, someone, someone thought that I was, like, in cahoots with some company who, like, just didn’t want them to use AGs or something. Like, I was, like, I was, like, I was part of, like, big failover cluster.

Like, the failover cluster industrial complex. I was, like, I’m not lying to you. Oh, Rowdy, were you copying and pasting, you sly dog? That came in real fast.

Rowdy says, I think every DBA has a story about that time the patch failed to apply and failed to roll back. That time the cluster did that weird thing. It didn’t come back up. The time storage. Oh, man. The storage one. Everyone has, like, well, everyone who has been on a SAN, been on a SAN, has that storage story. And, Rowdy, I tell a detail-free version of our story, of our time together, with that thing that didn’t go right on that server with all the databases.

I tell that frequently when people are, like, well, this is how we’re taking backups. I’m, like, y’all gonna have problems at some point. Problems.

Big problems. Big problems. I’m, like, yeah, keep doing that. Call me in a few months. Yeah, that was fun. I fondly remember the part of that call where, like, we don’t care about this database. I’m, like, cool, skip.

Start from scratch. Like, we never use that thing anyway. I’m, like, sweet. Not deal with that. Yeah.

But, I mean, so those are, like, those are great examples of production DBA-type problems. And, you know, if you do perf stuff, if you’re, like, a developer-type DBA, you’re gonna have problems where, like, you know, you create, you try to create that index and you cause blocking for three days. And then you hit cancel and you cause blocking for three more days because you had to, the thing had to roll back.

Or, like, you know, you tried to fix a problem and you, you know, created a bug with the fix for the problem. It’s, like, so many different things that, you know, you can all share that, like, you all understand the pain that those moments caused working with the database. Because, like, no matter what you’re trying to do with the database, there’s, like, this significant, like, pain that can be had when things go wrong.

You have to, everyone, everyone’s gonna come together on that. It doesn’t matter. You know?

I feel, like, I feel tremendous sympathy for people who need to manage complex, high availability and disaster recovery. It’s, like, I have tremendous sympathy. I would, my, my, my goose would be cooked on that. Not in a good way.

Not in a friendly Christmas goose way. Like, goose fell into the fire way. Rowdy says, I’m looking forward to pass to get to tell and hear those stories. Well, you know, I know you are, but here’s the thing, Rowdy. Passes all BI people and AI and machine learning.

So they’re just not gonna get it. They’re, they’re gonna stare at you like you are a caveman. And, like, you’re like your, uh, what’s his name? Sylvester Stallone in Demolition Man. Like, you just crawled out of a sewer.

Eating a rat burger. The blonde streak in your hair or something. No, I’m kidding. Passes, passes, uh, I don’t know. They’re doing their thing. They’re having fun.

They’re having fun this year. Hopefully they, uh, ignite some new curiosity. New passions in people. No one explained the shells.

This is a family-friendly, uh, YouTube broadcast. I actually read something very exciting that Spotify is testing a create podcast thing. And if Spotify introduces an easy way for me to create a podcast, I will podcast the hell out of this.

Because, gosh darn it, every other way I look into doing it, I, like, like, Libsyn or, I don’t know. It’s, I don’t know. It just looks weird.

I wish I could pay someone, like, five bucks an episode to just do it for me. I would make my life a lot easier while I stand here brandishing weapons, trying to fix a cuticle. Crazy, right?

So, like, uh, while I was, while I was on vacation, I tried to, I tried to use the time semi-wisely to, uh, since I obviously wasn’t going to the gym, to, like, figure out, like, okay, how can I be, like, uh, better at stuff. And the one recurring theme that I came across, like, literally every successful person.

Everyone, well, let’s see. Every, every successful person with a podcast that I, I, I, I tried to, like, read stuff from. Um, suggest, says you should meditate.

You should start meditating. You know, start easy. A couple minutes, five minutes, ten minutes. Uh, and just, like, meditate. Like, close your eyes and concentrate on breathing. Then, like, you know, there are some great meditation apps out there.

Now, like, I hear meditation app, and I get, like, dude, that’s, like, you know, you’re, you’re trying to do, like, this, this thing. Like, like, there’s an app for that seems like a real, you know, pardon my French, but I, I did just, did just get back from the continent. It seems real shitty to need an app just to meditate.

And so, you know, I will close my eyes and breathe for a little bit. Seems like a reasonable start to things, you know. Do it, do it if I feel stressed out or in the morning or if I’m banging my head against a problem that I can’t seem to make heads or tails of. So, like, do that, and then, uh, so I, I started to look at some apps that might, you know, like, might, might expand that horizon a little.

And so I’m, like, going through, I have an Android, so I’m going through the Play Store, and, like, I see a bunch of, a bunch of apps that are, like, like, free to download. I’m, like, you know, make me pay for this. Okay, you know, you put some work in, you recorded stuff, you should get paid for your work.

That’s, you know. Okay. But then you open up all of these apps, and the first thing they do is ask for your email address. I’m, like, you son of a bitch.

Never, I, it got me so stressed out. Like, I’m, like, ah, I’m going to, this, look at this app. It has a seashell for, for an icon. Oh, I’m going to be so relaxed in a minute. You open it up, and, like, there’s this, like, like, pretty blue sparkly thing happens. You’re, like, ooh.

And, like, if I, if I ever had sound on my phone, I’m sure it would have been, like, like, tinkling chimes and relaxing, relaxing wind, wind noises. But, no. Enter your email address. Don’t have an account? Don’t sign up with Facebook, and I’m, like, immediately just twitch. Lose my mind.

Like, the, like, the opposite of what meditation should impart on you is what happened to me. Like, just anger. Pure anger. Please enter your email address. Like, no, I’m not doing it.

I’m very angry about that. So, that was my experience with, with meditation apps. They’re dumb. They’re dumb, and don’t download them. Don’t encourage people who ask for your email address. That’s it.

I don’t know. So, now I, now I’ve, I’ve, I’ve, I’ve found, uh, there’s a kids channel on YouTube. Called Pure Star Kids. And if you, if you just search on YouTube for countdown rainbow timer, you’ll find all of their videos, which range from, like, one minute to, like, an hour. But it’s just, like, a picture of a rainbow that’s, like, semi-animated.

And, and it counts down. And at the end of the, the countdown, there’s, like, birds chirping that plays. And if that’s, that’s about my speed. So, no, no guided transcendental tantric yoga chakra clearing talking voice meditation for me. I’m just gonna close my eyes and fall half asleep and wait until I hear birds chirping.

Something like that. I don’t know. See if that works. We’ll see if that works or if it’s just a waste of five minutes of my day. Who knows?

Who knows? All right. No one’s asking questions anymore. And I’m, I’m getting to the point where I’m just rambling. So, uh, I’m gonna call this one a day. Uh, I will, now that I’m, I’m, I’m, I’m back, I’ll be here next week, too, as long as no senseless tragedy befalls me. Anyway, adios.

See you next week. Thanks for showing up. You’re all sports.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I discuss how to improve query performance by addressing plan warnings and residual IO on index scans. I explain that such warnings often indicate the need for better-indexed columns or additional indexes to optimize data retrieval efficiently. The discussion then shifts to a lighthearted note about my current state—feeling unwell due to weather conditions, which are particularly bothersome as I age. Despite feeling under the weather, I engage with viewers by answering questions and sharing some personal music preferences, including “Procession,” “Your Silent Face,” “Age of Consent,” and “Bizarre Love Triangle” from New Order. The conversation also touches on Azure managed instances, expressing both enthusiasm for their potential and acknowledging current limitations, while emphasizing the ongoing improvements Microsoft is making in this space.

Full Transcript

I feel like crap today. No one shows up. I’ll be relieved. Oh, someone showed up. Now I have to stick around. Darn it. Darn it all. Two people showed up. Oh, God. Now I have to stay for twice as long. That’s how it works, right? You guys are exponential. Oh, all right.

You’re very quiet people, though. Don’t even say hello. It’s rude. Rudy, Rudy Poo. There we go. Finally. Finally. Four people. My goodness. I didn’t realize that many people were so thirsty for SQL Server. Who knows?

I’m a little bit more. I’ll take that back a step here. I have no idea how much of this content will be SQL Server related compared to other things. No idea. We’ll have to wait and find out. We’ll see later.

Lars asks, do your AG listeners use NTLM or Kerberosoth? Good news and bad news. The good news is I don’t have any AG listeners. I mean, good news for me. That’s great news for me because if I had AG listeners, I would be doing things I hate. The bad news for you. The bad news is that means I don’t know. And, you know, I’m going to go out on a weird limb here. I don’t think AG listeners use either one. I think they just handle where the request gets sent and the type of authentication is handled by SQL Server when it arrives there. I don’t think the listener does any of that. Listeners are very, they really don’t do a lot. Listeners kind of don’t do much at all.

Listeners are kind of like, I don’t know. Weird, dumb, lazy things. SPNs won’t create for listeners. I’ve never tried to create an SPN for a listener. As far as I know, they don’t, yeah, they don’t need them. Darren, Darren, thank you for, thank you for chiming in, Darren. Yes, listeners do not need, require, get SPNs. They’re quite virtual things. I forget what, I forget the conversation that I was having about listeners before my friend, Mr. Sean Gilardi from Microsoft. I forget, it was, like, someone had asked a question on Stack Exchange, like, like, how do I fail a listener over or something? And it was just like, you don’t, they’re not that real. They’re not, like, physical things. They are very virtual.

Seems like they should use Kerberos. Yes, again, as far as I know, they just direct traffic and then the authentication is handled by SQL Server, not the listener at all. I don’t like that. I think that they just, they do nothing except say, you go here, you go here, you go here, you go here. Or everyone goes here because we don’t, we don’t want to pay $7,000 a core for over there. We just want to pay over here and pay software assurance. Host names. Host names, yeah, host names indeed.

Oh, man. People wonder why I just stick with performance tuning. All this other stuff is hard. Hard. Too much for me. Stick with query optimization. The optimizers are much more simple. Dependable and reliable than all this HADR stuff.

People are crazy with it. Yeah, perf tuning is really easy. You just throw a no-lock hint on everything and stick stuff in a temp table and you’re done. That’s it. Add an index once in a while.

Look busy. Twiddle your thumbs. Yep. Waiting for that index to build. Let me back in a bit. Oy, oy, oy.

So Lee asks, what kind of approach would you take to getting rid of table spools? I know indexes can help alleviate these, but what if that doesn’t help? So spools generally happen on the inner side of nested loops because SQL Server is terrified of doing vicious repetitive work. Especially if you have non-sargable predicates that are like the result of, you know, like is null or date at or date diff or something.

You know, join or where clause. That can certainly contribute to it. So like you see a lot of like L trim, R trim, replace in your joins and where clauses and they end up on the inner side of nested loops.

There’s a pretty good chance that SQL Server is going to use a table spool. So two things that is a repetitive work. So obviously nested loops, right? So something’s going to happen a whole bunch of times and SQL Server is afraid that the work is going to be repetitive. So what you’ll often see is the outer side of nested loops.

Maybe sort data before the nested loops join. And what happens next is funny. So SQL Server will take the data from the outer side of nested loops. Maybe sort it to put it in order.

If it’s already in order, then it doesn’t bother. It just goes into the nested loops join. On the inner side of nested loops, you’ll have that table spool. And what that table spool does, if it’s eager, is SQL Server will sort the data from over here. Or sort it if it’s not already sorted.

So that repetitive values from the outer side will be in order, obviously, right? Order is important. So what happens is SQL Server takes them. And so that it knows if the value one comes out over here and the next 10 values are one, it can take that spool, go run the subtree, get all the subtree for the value one, bring it into the spool, and then use it 10 more times.

So when you go get that first initial value, that’s a rebind. And when you go reuse the spool for that initial value, it’s a rewind. So rebind on one, rewind 10 more times for one, and use the data in the spool.

The next value is 2, and let’s say that happens 5 more times. You hit this, you go get the data for 2, bring it into the spool, and then reuse it 5 more times. So a rebind and then 5 rewinds.

If you really, really want, one of the best ways to get rid of table spools like that is to tell SQL Server that the data coming from the outer side is unique. So you can do that with either a select distinct, you can do that by dumping something into a temp table and putting some sort of unique clustered index or primary key on it.

Sometimes you can simply select distinct values into a temp table and then use that instead. And that’s generally the best way to get rid of the table spool is to separate the repetitive work, or remove the repetitive work, rather.

So when SQL Server knows that it’s only going to see 1.1 and 1.2 and 1.3 and 1.4 and 1.5 and so on, then it stops. Then it stops trying to do the spool.

Yeah, unique. All right, so if you have a set of numbers that are, let’s say you have 1 to 10, and that’s you have 10 1s and 10 2s and 10 3s and 10 4s and 10 5s, that’s not unique. But if you select distinct, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, you have one value.

And you can go get just that thing for 1, and then we’ll get the thing for 2, and SQL Server won’t. Does select distinct into a set of uniqueness flag? Well, when the statistics get built on that, then SQL Server will probably figure out pretty quickly that things are unique.

If you do that and you still don’t get rid of the spool, then you probably will have to add a primary key or unique clustered index on that temp table. I generally tell people to avoid nonclustered indexes on temp tables because if they’re not wide enough for the query, then they’re not going to get used, and then you’re maintaining the heap structure of the temp table plus the nonclustered index structure on the temp table.

So if you’re going to index a temp table, please make it a clustered index. Otherwise, you’re just maintaining two temporary objects, which I think that’s pretty dumb.

I would never do that. But yeah, heaps get statistics too. Heaps are not opposed to statistics. The only thing that doesn’t is the old table variable. I don’t think you can add those to temp tables, Lars.

I don’t think you can add constraints like that to temp tables. I want to say tempDB as opposed to foreign key and uniqueness constraints like that. You can add a primary key because that’s an index on the table, and that’s sort of a different beast, but I think unique constraints and the foreign keys and stuff like that are off-limits for temporary objects.

I remember, or at least remember a few times trying to do demos for foreign key stuff and using temp tables. Yeah, you can’t foreign key in tempDB.

It’s just not a thing. Not a thing you can do. I remember one time a while back, I was trying to write a demo using foreign keys. By the way, Peter, very funny. YouTube asked me to approve that comment, apparently because it thought it was dirty words.

You were trying to tell me to FK myself. So I remember trying to do some demos in tempDB about foreign keys, and I remember getting a bunch of errors like, you can’t do that here, or I could set it up, but it wouldn’t work.

And I was like, what the hell is going on? I was like, oh yeah, tempDB. It’s always tempDB. Always, always, always. Always, always, always.

Damn you, tempDB. I would love to go foreign key myself and then take a nap. I feel like crap today. It’s hot, and there’s thunderstorms coming, and since I’m old, weather has a disparate impact on my sinuses.

And so whenever things get high pressure outside, they get high pressure in my head, and I spend the day wondering if I need to go to the hospital. I’m like, is my brain about to explode? What’s happening? I don’t feel like I’m here right now. My hands don’t work right.

So things like air travel and bad weather are a lot of fun when you get old. Lee, you can ask all the questions you want because I have approximately 17 minutes to kill, and no one else is asking them, so please ask away.

Ask away. Question is, the plan warning operation caused residual IO on the index scan. Would you say that this is an area I should focus on with a plan when trying to improve query performance? In my example, the actual rows read is far higher than the amount of rows returned.

So sure. I think you’re going to see that warning in Century One Plan Explorer. I don’t think that’s in Management Studio. And when the reads are far higher like that, I’m actually writing a blog post sort of related to this. It generally tells me that the index keys are maybe not in the right order for that, or we don’t have a good index to find that data.

So if, you know, just as a quick example, let’s say that we needed to find like where reputation equals two, but either we don’t have an index on reputation, or we have an index on like another column and then reputation, SQL Server can’t easily seek to just the values we need for that.

So that might be a case where the, what do you call it? The index columns are in the wrong order. So if you put reputation first, you could easily just find that. That starts to matter much, much more on larger tables because you would, you know, if let’s say you have a 500 row table and, you know, you have to read 500 rows to find 200 values.

So what? If you have, you know, like a 10 million row table and you have to read 10 million rows to find five values, that’s much less fun for everybody. So check your indexes, make sure that you have a good index to find that data, find the data for your predicates or joins or whatever that you’re looking for.

And then if you don’t, I don’t know, go, go create one with no lock middle of the day, maxed up 57, something like that. That’s usually how it works, right?

It’s usually how it works. Let’s see. Uh, the next question we have is a good question. Wow. What are your top four new order songs?

Um, let’s see, probably procession, I think is my first one. Procession is first. Uh, your silent face would be second. Right?

So procession, your silent face, uh, probably age of consent. And then bizarre love triangle. I think those are my four. I almost wish that, um, I almost wish that 24 hour party people was a new order song because that would have snuck into the list.

If it was just not happy Monday. Let’s see. Does the Mac behind me boot? Yes.

Yes. It does. It boots up. I can use it. I even have a bunch of dumb discs and games for it. It’s just, it’s just very slow to use. This is the ravages of time. Just try this. Uh, let’s see.

Let’s catch up on some comments and questions here. Um, uh, let’s see. Lee says in the example, the actual rose, right? Oh, we already covered that. Uh, SQL WB says, Eric, if you’ve done any dabbling in Azure managed instances, I’m still on the fence since they have so many restrictions as compared to standard Azure setups. Yeah.

So, um, I really love where they’re going with them. They’re sort of like brand, brand new. Um, you know, they, they just like pretty recently got general availability release. And so, you know, I, I really like where they’re headed with them. Like, uh, the, the PM for those Jovan was on Twitter asking about, uh, DTC and how people use it and how if they implemented it up there, like how they would want to use it and what they would want to see from it.

So, you know, it’s, there’s lots of, they’re making progress with getting things like more on par with the box product, right? They’re slowly adding in things. This is no small undertaking to get this going. So like the cool part about Azure managed instances is that you get Microsoft, I mean, for better or worse, right?

We don’t know, cause it’s the cloud, right? Which is like Airbnb for your, for your data, right? You’re, you, you, you paid for it, you paid for the space, but it’s still someone else’s apartment. And you have to like wonder if like, you know, I don’t know, just herpes on the toothpaste or something. But anyway, so like, uh, I love where they’re going with it.

I love that they’re coming out. So Microsoft manages your backups. Microsoft manages, uh, the high availability. It has the same restriction where like once data goes in, data, getting data out is not quite as good. It’s on that like weird internal version of SQL Server that gets used in Azure. So, you know, um, they’re, they’re, they’re getting better with it.

And I like, uh, I like what I like. I like the idea behind them. And I think that that’s what Azure SQL DB should have started out as, but you know, better late than never. And I’m sure that, um, you know, I’m sure that is they mature and become a more competent product that, you know, the, the issues that perhaps Lee is running into and the roadblocks that you’re, you’re finding for, uh, you know, getting your workload up there and running will diminish.

So, you know, give it time, you know, it’s like anything early adoption, early adopters always have the most pain, but they also get the best prices because, you know, let’s, let’s face it. You were like, I was with you when you were terrible. Like you owe me money.

It’s like my wife. Like I was with you when you were broke. Buy me a Louis Vuitton bag. FK to self. Also the initial setup time is, uh, a little painful for me.

Genses is right now. For some reason, the first time you create one, it takes like a week. I don’t like, I think they have an actual person like, like, like wiring things in and like going to do stuff. They have to like, I don’t know. I, I picture some like, some like weird Kung Fu master, like prove you’re a Kung Fu master thing where someone has to like, sit in the Lotus position where they get beat with sticks and not feel anything.

And then like ascend a mountain and pick a flower and then like go underwater for 30 minutes. And so like, there’s like someone must have to go through some real, real misery to get those things set up. And yeah, the amount of time it takes.

Someone’s, I think someone’s like, someone goes out and buys a computer. They’re going on Dell.com. They’re like, Oh, we got to figure this out. Like, what do they want? 512 gigs of Ram. Oh, it’s expensive. Charge them extra.

Yeah, it is. It is. It, it, it’s a, it’s a, it’s a union estimate is what it is, man. The trades are slacking in that data center. It’s like, we will show up.

We’ll probably be there. We’ll be there within this four hour window. And if for some reason we won’t be in the, there in that four hour window, we will call you at hour five and tell you that we might be four hours late. Yeah.

I think if you work in any data center, your, your title is order monkey, because you are trying to bring order to that chaos. I read someone on Twitter was saying that, uh, their data center went down because a drunk driver hit like a, an electric pole by there and knocked out electricity.

And the battery power did not last as long as anticipated. The battery power lasted for like two, two to four hours or something. And then it just by everything shut down. Yeah.

The other tough thing about, uh, the cloud and managed instances, um, is that, well, so like you have, if you’re on prem, right, if you are living on, on planet earth, like the Duran Duran song, and you have multiple environments, like you have a production environment that you do all your real work on, you pay, pay for that.

And then you have, you know, dev or UA, UAT or QC or whatever lower environments, uh, you can use, you know, developer edition for those and you can use whatever you want for those. And it doesn’t really cost you much aside from like the hardware. Up in the cloud, there’s no real classification for like, this is just a development server.

If you need to have a development server, that’s in any way lined up with the specs of prod, you could end up spending a pretty serious chunk of change. And that’s, that’s kind of a big, big stopper for a lot of people who are like, wait a minute, but where are we supposed to test this stuff?

Microsoft’s like, then just speeds off in the solid gold Bugatti. It’s a, it’s tough. It’s expensive. It’s like, Oh, you wanted to rent another Airbnb.

Okay. That’ll be twice the price. Sorry about that. Should’ve read the fine print. Oh, he says one final point. SSMS is still not up to speed with managed instances. Although the past month has been better.

Let me tell you about SSMS 18. I wish that I could do it. I’ll, you know, I’m going to, when I get done with this, I’m going to record a video because when I use SSMS 18, there are two things that constantly make it crash. They irk the hell out of me because it’s, they both have to do with extended events.

And it’s not because I use extended events a lot. It’s that when I do use them, I just want to be able to use them and get the hell. They’re not, they’re not fun to use. So if you open up the extended events GUI and you say, I want to have a new session.

And then you, let’s say enter a name for the session in that first window. And then you click on events, which is the next node down in that little left side piece over there. It just crashes. It goes unresponsive and crashes. Goodbye. That’s it. Done.

Done. The other thing is if you like say use management studio 17.9 and you create a session there and you get it running and then you say an SSMS 18.1 watch live data, you can do that, right?

And live data starts streaming in. But when you close that watch live data window, SSMS crashes. It just says goodbye. And so it, it, it, it makes me wonder. It really makes me wonder, I truly wonder if anyone tests this stuff. I get the feeling that they don’t because those, those are two pretty huge usability things.

And if you like, it doesn’t take much poking around to discover those. It takes nothing. Nothing. Ridiculous. Let’s see. Azure data studio.

Oof. I haven’t even downloaded it. I don’t, I don’t care. I’m going to be completely honest. I don’t care because all of the things that I do revolve around query plans and query plans in Azure data studio are garbage. They just, they, they, they don’t have anything anywhere near the level of detail that the ones in management studio do.

And I am not excited at all about the plan explorer add in because what the plan explorer add in doesn’t give you is a lot of the operator time stuff. And it doesn’t give you, I really, I, the way that you can, the way that plan explorer handles parallelism and showing parallel threads and row counts where it’s like in some weird tab four bars over and it’s like row by row.

And like, there’s like a column. It’s not, not easy to look at some things in plan explorer. There are some things it does quite well.

Um, but, uh, like, like if I had to, if I have to troubleshoot a long store procedure, uh, plan explorer is the first thing I’m going to go to. But with the operator time stuff and the, the parallelism stuff, most of, most of what I, what I’m doing these days is in SQL Server management studio 18, which, which, you know, it makes it frustrating because you have these awesome advances in one area, but you have these, you know, just terrible crashes in other areas.

So it’s like, well, why did I didn’t, does anyone over there use extended events? As I wonder, I wonder, I wonder, I wonder. Azure data studio was great for worksheets. I don’t even know what the desert worksheet is. Nope.

I like it. Oh, it’s too much. It’s not, it’s not my thing. Like, I’m glad it works for people and it solves problems for people, but it’s not, not my jam. Azure SQL serverless. Serverless is a lie.

It’s like saying this can is canless. It’s on a server. Good for demos. All my demos revolve around query plans. What am I going to show people? HTML, paste the plan.

There’s no, there’s no, there’s no, all the detail on that is not there. Not with the stuff that I want to show people. It does not have that in there. No, no, no. I would, I need, I need the good query plans. You put the good query plans in Azure data studio. We can talk.

Then we’ll talk. Then I’ll think about it. Well, it’s just, you know, different tools make sense for different people. You know, some people are very like, Oh, you got to use visual studio code for everything.

Oh, have you tried notepad plus plus? I’m like, doesn’t do what I need it to do. Different functionality. So I was just like, man, I really want to show you this execution plans. Like, have you tried power shell for what? It’s not what I need.

I want to show you this query plan. Well, have you tried DBA tools? I’m like, man, it’s not what I need. I need this stuff. Yeah.

That’s the other thing is I don’t want to have to learn a whole new thing right now. One of my favorite tools other than SSMS. I mean, again, plan explorer for, uh, for big store procedures where I, where like management studio is just an utter failure for displaying those.

Uh, but other than that, I don’t, I don’t use a whole lot. I’m pretty low fi. My stuff, you know, I, um, keep a lot of stuff in text files. Uh, you know, I, I w I was a big MS paint guy until I, um, I started using snag it for my screen caps and they have a pretty decent photo editor in there.

So, some people, some people, he just says, my wife is very judgy when she catches me in MS paint.

Well, you know, what, what does she use? but she has a Mac with $7,000 Photoshop product on it. It’s messed up. MS paint is awesome. Remember, good old days of MS paint.

She does have them. Of course she does. You know how I knew that? Photoshop may be involved. Yeah. You know how I knew that? Hmm. Very intuitive, very intuitive person. Know everything.

Know everything. Evernote. Evernote is good. Yeah. I use it. I, I use Evernote. I probably don’t like fully utilize it in the way that I should. Like it’s, it’s Evernote is kind of like a junk drawer for me. The only thing that I, uh, I consistently use it for is like workout stuff.

So I can just like put stuff in there real quickly, update stuff, make notes. But, um, yeah, aside from that, I’m, it is, it is pretty much just a drunk drawer of like, I like this picture. Sure. I would like to do something with this picture. Eventually.

Hmm. I haven’t used OneNote though. I know Buck Woody had a tweet or a blog post about how he uses OneNote for all sorts of crazy things. And I realized that my life is not nearly as complicated as his. And that I, I don’t need that level of functionality.

I just don’t. So, wake up, stave off the hangover. Eat some breakfast, work, continue working, go to the gym, come home, continue working, start drinking, eventually stop working because this is too much drinking.

Go to bed. Paints a fun picture of life as a, as a consultant, doesn’t it? I’m, I’m mostly, mostly joking. That’s most of my, most of my days and nights are not that, that difficult. I felt.

very, very rarely is there a weekend, weekday hangover rather. It’s not, not big on the, the week, the, the weekday drinking because, I don’t know. I, I feel like if I’m going to go to the gym, it should at least hang around for a while.

Right. At least give it a fair chance. And if I drink during the week, I don’t give it a fair chance. So don’t do that. Really special occasions. Once in a while, weekend warrior of sorts. Terrible word.

That is. All right. We are about, we’re a little over the half hour mark and that is all I am contractually obligated to deal with you people for. So I’m going to get going and open, open my door and let the air conditioning back in. Thanks for hanging out.

Thanks for all the great questions this week. And I will, I’m not sure about next week yet. We’ll have to wait and see. I’m doing a bit of traveling. So we’ll, we’ll figure out if I have the bandwidth to do this. Also might be at a slightly different time. It might be, it might be at a time that makes Europeans very happy.

We’ll, we’ll see. All right. Take care. Goodbye.

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.

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Video Summary

In this video, I delved into some detailed SQL Server performance tuning scenarios and queries related to memory management and query optimization. I started by discussing the importance of monitoring memory usage in a database environment, particularly for an OLTP system where user queries and reports are frequent. We explored how to identify and mitigate memory pressure using tools like SP_BlitzCache and resource governor, as well as how to manage memory grants with hints like `MAX_GRANT_PERCENT`. For ETL processes in data warehouses, we discussed the potential impact of memory pressure on columnstore index compression and load times.

I also addressed a specific query from Justin about singleton lookups, explaining that these are typically associated with key lookups, especially when using nonclustered indexes to find partial data and then needing to retrieve additional columns from the clustered index. We used `SP_BlitzCache` to track down expensive key lookup warnings and reviewed how `sys.dm_db_index_usage_stats` can provide insights into index usage patterns in query plans. The discussion highlighted the importance of profiling workloads and capturing detailed query plans to diagnose performance issues effectively.

Full Transcript

All right. There we go. Yay, audio. Yay, audio. I don’t know why this thing decided to start picking a different microphone, but now I just have to remember to check that every single week. The rest of my life.

Now this is, this is a kind of thing that’s going to make me move to Twitch. I can’t share screens. I can’t have multiple people. The number of things I can’t do is amazing. So yeah, I’m thinking about getting off of YouTube for this.

As much as I like being able to… Yeah, sorry about that, Forrest. I don’t know why. I don’t know why. I couldn’t tell you. This is, this is why I’m thinking about switching this thing over to Twitch, because YouTube is very limited in what it allows me to do, aside from a stand here, like a monkey looking for props.

Like, this headband that my daughter made me. Unfortunately, the flower has fallen off of the headband. I’m sure I’d look just as creepy in it either way.

So, I’ve got that going for me. It’s a good time. I also, I love the smell of gardenias, gardenia flowers. I like magnolias too.

And silver linden, I believe they are. But I particularly like the smell of gardenia. So, I bought a candle. It said gardenia on it. There it is. Gardenia. And what I didn’t realize when I bought it, is that it’s a creepy candle.

Because when the candle melts, it turns into massage oil when poured. Melts into massage oil. So, now I’ve got this creepy candle in my office.

And that’s that. It smells nice though. It smells wonderful. It smells exactly like gardenia. I don’t know how they do that. Fantastic. Fantastic scent of gardenia. I just have to forget that it’s creepy.

It’s a creepy candle. I don’t know. I don’t really have anything else interesting over here. Right now. Yeah.

This is it. So, let me ask. Are you able to access Zoom conferences from work? Do you use Zoom at work? Do you use Zoom at work? Not Zoom like the MP3 player. Zoom like the thing that SQL Server does.

Z-O-O-M. Because Zoom offers a little bit more flexibility. It’s not quite as. Yeah. So, Zoom is a little bit better for that kind of stuff.

But. You know. It’s not quite as. Just show up on my YouTube channel and hop right on. It’s kind of like. I’d have to. Set up. Invites or. I don’t know. It’s weird. Anyway. I would like to collect as few email addresses as possible.

For. For things in my life. Anyway. Uh. Yeah. So. Maybe I’ll do that. And. And tech.

And tech. Not tech. The technological news. I. I ditched my Fitbit. I have thrown my Fitbit away. The thing is useless. It has never given me an accurate reading. On anything. Ever. Not sleep.

Not heart rate. No. Gone. No. It’s not a cardio thing. It’s a. I don’t know. I. I just don’t. I don’t think. I don’t think. Me and the Fitbit ever.

Ever quite got along. I think we are always at odds. Because. I would do things like. Sleep. And it would do things like. Tell me I’m awake. For hours. I don’t know. Anyway. We do have a technical question this week. Can you believe we have a technical question?

Hello Alex. Hello. Gather Uncle. Hello everyone. Uh. We have a technical question. From. My friend Ted. Who unfortunately can’t be with us today.

He’s not dead. Don’t worry. He just. Had other things to do. And. Ted says that. He has a server. That he thinks is under memory pressure. And when he looks in. Sys. Dm. Os.

Memory. Clerks. To see how memory is being used. He sees what you’d. What will. Something you wouldn’t expect. For an. OLTP or server. Now. This server has a 360 gig. Database on there. Uh.

Ted didn’t mention. Ted didn’t mention. How much memory. The server has. But. Uh. He did say that when he looks in. That dmv. Um. That. Let’s see if I’ll make sure I read this right.

See the SQL optimizer. Entry has. 22.4 gigs. The object store lock manager has 5.6 gigs and SQL buffer pool only has 1.4 gigs. Should I. And he wants to know if he should be concerned.

Be concerned about that. And. The short answer. The short answer. Is yes. Yes. You should. Because. The entry that you’re seeing. The.

The entry that’s in there. For. Uh. Memory clerk. SQL optimizer. Is. The memory clerk that gets. Populated when. Uh. You are giving out memory grants. To queries.

So when you. Have a query that does a. Big sort or a big hasher. You. Small ones. You have to give that thing memory. And when you give that thing memory. It has to come from somewhere. SQL Server and windows do not go into cahoots.

Or collusion in order to make more memory for you or to. Compress things in memory or. Do anything else. Though. What happens is you. You end up mostly taking memory from. The buffer pool. And.

So. One other way that you can validate this is if you look in. Uh. Some of the perfmon counters. If you look at the stolen pages. Perfmon counter. You’ll be able to see. How much. Uh. Aggregated. Uh.

Memory has been stolen away from the buffer pool. So. The. Quick answer is that yes. This server is definitely under. Memory pressure. And yes. You should be concerned. But. You should also try to correlate it with some events. So.

First. I think what I would look for. Is. Resource semaphore weights. Because resource semaphore weights are most likely going to show up when. Queries are waiting on waiting to get memory to run to do those. Sorty hashy things.

We don’t want to judge the severity of the memory pressure. So we’re going to look at stolen pages. We’re going to look at look for resource semaphore weights. And. And then. Uh. Well. After that.

You know. You’re going to have to figure out a way to figure out when those weights are happening. Right. So you could try logging SP who is active to a table. If you don’t have a monitoring tool. You could get a trial. Monitoring tool. I would suggest. Sentry one performance advisor. Uh.

Get a trial of that. Set it up and try to figure out when. These memory weights happen. You can be able to see very clearly in. In the. In the dashboard there. When. Memory is tanking. For. And. Hopefully be able to track it down to some query activity. So like.

You know. Stuff that is definitely. Going to. Um. Cause memory issues. Uh. If you. Have. You know. 360 gig database is your biggest one. Well. If you. If you don’t have. A lot of memory on that server. Say.

That server is a standard edition box of maybe. 64. 96. Or 128 gigs of RAM. You’ve got way more data than RAM. And when you need to do things like run check DB. Or. Read a big table in some other way. And it has to come from memory to. This is going to knock a lot of other stuff out of.

Out of memory. And then on top of that. You’ve got. The potential for. Query memory grants. To be at odds with even things that you’re trying to read into memory. Just. Gnashing teeth.

Together. So. Yes. I would be concerned. But I would also want to. You know. Measure my. My. My concernedness. Make sure that I am. It. Like. It makes you wonder if. This is just something like.

Like. You were running some scripts you found out there on the internet. You just. Went and hit F5. Some stranger said. Hey kid. Run this script. And you ran it. And. You saw that. You saw this happening. But you know. It’s one of those things where it’s like. Well. Are users complaining about it? Is this something that.

That happens. During maintenance. Like. Say you rebuild a bunch of indexes. Or reorg a bunch of indexes. Read a bunch of stuff on into memory. And then that happens. I don’t know. It’s lots of things to think about. Because. Index rebuild and all that require. Memory too.

When they. They sort data into index key order. Every single time you run them. Crappy. Crappy. Anyway. Gazaranco. Says. Is. On a similar subject.

For ETL DW server. Would you care about memory pressure. E.g. Truncating everything. And inserting each day. So not OLTP. I would not. Well. That depends a little bit. So if it’s a data warehouse.

And. You. Are using columnstore indexes. And you are coming under memory pressure. You can end up. With. Poorly. Compressed.

Row groups. Because. The memory pressure will not allow. You to read in. Big row groups. And compress them. Something like that. Joe Obish explained it once to me. And this is as much as I can remember. My. Louvre. Addle brain.

But yeah. So there. There are times when I would worry about it. If you’re using rowstore indexes. Perhaps a bit less. If you’re hitting. If you’re hitting memory pressure. For. Load queries that are. I don’t know. Again. Sorting. Hashing things. It might slow them down a bit.

But. You know. That’s. That’s kind of up to you to figure out. If I’m hitting a lot of memory pressure. When users are running queries. Or when reports are getting generated. Then I might pay a little bit more attention to it. You know. If. So. If ETL load times are cutting into.

When people need to run reports. And sure. I would worry about memory pressure. Then. Because perhaps memory pressure. Is the reason that. Things are slowing down. And if. You know. Because you don’t. You don’t want loads to still be going on. When people are trying to generate reports.

If that’s not happening. And people are just. Hitting. Memory pressure. When they run reports. Well. It’s a little bit of a different story. You know. You do need to exercise. Some. Caution. And. You know. The way that.

You. You let people do things. So. There. There are. A couple of things that I would explore. Maybe. You have. A bunch of processes. That.

Are all asking for too much memory. In which case. You could. Use resource governor. Or if you’re on a newer version of SQL Server. Like 2012. SP3 plus. Or something. You could use the max. Grant. Percent hint. To limit the amount of memory.

That a query asks for. You can reduce memory pressure quite a bit. By reducing the memory grants. That queries are asking for quite a bit. You know. If you have. So. What I would. Do is. Try running.

SP blitz cache on there. See if. Any of your queries. Are getting the unused memory. Grant. Hint warning. You might see that. If you’re on. A new enough. Version. You might see that in there.

If it’s. If it’s in the DMVs. Other things that you could look at. Well. You do. Kind of be on a query by query basis. You would have to. You know. You would have to profile queries. In some way to. Like. Use extended events.

Or. Profilers. Like. I don’t even know. I don’t even know if that’s in profiler. Jeez. You might have to just use extended events. Or. Or. Or. Or trace things. In a specific way. To see. How much. How much.

Like. You could use. Sys.dm resource. Semaphores. And. The memory grants. One. To see if. Queries are. Using. The amount of memory. That they’re being given. Stuff like that. So. That’s one. That’s what I would look at. That finishes in time.

I just feel it could be quicker. Well. I don’t know. What makes you feel that way? Is it. Like a. I guess. Or. Is it. Rooted in fact.

At some point. I don’t know. I don’t know. I don’t know. What you’re up to over there. You crazy kids. Your ETL processes. Let’s see. Justin. Justin. Has a question. I’m going to go for this. Justin.

I’m not going to read ahead. I’m just going to read the question. As I look at it. I’m. I’m avoiding. I’m averting my eyes. So I can’t see it. Justin says. Could you shed some light. On what events increment. Singleton lookup count. I have an index. It has zero scans and seeks. But millions of singleton lookups. Yes.

Usually. Key lookups. So where you. Where I see that most commonly. Is with the primary key. And or clustered index of a table. Where you have. Say some narrow. nonclustered indexes. That help queries.

Find certain bits of data. But they don’t cover all the columns needed. By. The rest of the query. Say that. That. So you have like a single. Column index. God forbid. On. On a table. And. You know.

Your query is like selecting three columns. From that table. Where your. Single column index. Equals something. And so SQL Server says. I’ll use you. Little index. I will. Find this data. That I’m very interested in. And then I will. Go back to my cluster index.

And I will find. I will get the rest of the data needed. For this. Query. So that’s usually when I see it. That’s what I would look for. Again. You could. If you’re. If you’re. If you’re. If you’re. If you’re. In perhaps tracking the source query. For some of this stuff down.

What I would do is grab. SP bliss cache. From. The first responder kit. And I would. Run that. And I would look for. Expensive key lookup warnings. If you see. Expensive key lookup warnings. You may have found your culprit.

If you. Crack open some query plans. And you see. Key lookups in there. And all that. And you. Of course. May have also find your. Culprit. But yeah. That’s usually what I see. Driving that. That thing to take up. It’s a lot of fun.

Learning about this stuff. Isn’t it? A lot of fun. The other fun thing. About. Sys. Dmdb. Index. Usage.

Stats. Is that. They. Will. Show you. Or. Rather. Sys. Dmdb. Index.

Usage. Usage. Stats. Is that. They. Happened. Or show you. Usage. In query plans. If that. If there’s an operator in the plan that is accessed. That table in some way. Even if that operator doesn’t execute.

Fun. Operational stats is even crazier, but. We’re not going to talk about that. Justin says I have searched the last three months of query plans and no lookups on that guy. Oh, I don’t know. Were there any.

Was it on the inner side of nested loops anywhere? Where do you have. These query plans saved to. These three months of query plans. That’s what I would be. That’s what I would be very interested in.

Where did you. Where did it come from? And see it just updates. Oh yeah. I’m not sure then. You might need to. Profile your workload in some way that allows you. To capture queries that specifically touch that table.

You know, like there’s a lot of reasons why plans don’t get cached. Or why plans might not be. Collected for various reasons. You know, recompilations hit like saying recompile recompilation events. Using temp tables, you know.

Server memory. There’s all sorts of reasons why you might not see something in there. Redgate SQL monitor. You know. You know. You know.

You know. All right. Uncomfortable silence. I might want to. Perhaps try monitoring the server in a different way. That. It captures things a bit differently. Would be.

Would be. Would be my first suggestion. Again. Sentry one performance advisor does a very good job of capturing. Plans like that. And you know. Telling you when they ran and what weight stats went on. And kind of what they did in there. And you can even query the.

The repository directly. To. You know. I believe they might log. Stuff like that in there. Because I know that when. You open plans up in plan explorer. They tell you the. The lookups. And all that stuff. And I know that plan explorer is built into performance advisor.

So. There’s all sorts of stuff that you can find in the repo that. That might. Might show you. A different perspective. On your server. Anyway. No problem. Happy to answer. Happy to. Have something of moderate value to contribute.

Once in a while. Once in a great great while. All right. Let’s see here. Uh. Uh. Uh. Well. Okay. All right. No questions over there. We have questions over here. No.

All right. It’s a 500 gig index. And I was hoping to get rid of it. Is that clustered? Non-clustered? What kind of index is that? Non.

Oh. Oh. You have. Lookups against a non-clustered? Well. Then. You’re not going to find key lookups there that help. I would just look for where. That call. That. That index is just on the inner side of a nested loops join. Perhaps.

That might. That might. Might. Might lead you to some. Might. Might lead that horse to water. Uh. 500 gigs. Yeah. Someone. You could just take that column out of the index. I mean. That’s what I would do. There’s no.

No need to have multiple copies of that. That’s. Well. I mean. I could say there’s no need. So like if. You know. Say you ever. God forbid. Hit. Database corruption. It might. You might be thankful. Someday that someone is like. Oh yeah. We have.

We have another copy of that column in this nonclustered index. We can just. We can just put it back from there. But. You know. Oh. I would. I would much rather just have a good backup. Cause now. You know. Your backup is going to be 500 gigs bigger because of that index. Damn it.

I’m sure it’s not just that columns fault. I’m sure there are some other bad choices in there. But. Who am I to judge? Who am I to judge? Who am I to judge? Who am I to judge? Who am I to judge? Who am I to judge? Big old nobody. All right.

Do we have any other questions? Does anyone else. Have something they want to know about? Cause I am ready to go to bed. Ready for sleep. I mean.

Maybe a nap or something. I don’t know. I don’t know. I don’t know. I don’t know. Peter says, I always read the docs to mean that. An index on a VARCAR max is only an index. On the VARCAR 900 portion of the field. Uh.

I’m not sure that. That’s the case for. Included columns though. And that’s the thing. Is included columns don’t have any restrictions on. All right.

Alex says, I’ve got a couple of tables with aggressive indexes. Total lock weight times greater than five minutes row and page with short average weights by SP Blitz index. There was a high number of lock escalation attempts with zero escalations. All are clustered IDXP case.

What is the best course of actions to resolve the issue? Um. Well. That’s a fairly easy one. If you don’t have any nonclustered indexes on the table, then you’ve got your answer. Is that everything that goes in and out of that table, all the traffic, whether it’s a modification, you know, insert, update, delete, or a re query just to select has to go through somewhere. And those indexes are that indexes that somewhere.

So it might be a good idea to check out what indexes you have on there. You know, if they’re, if you just have a clustered index primary key, no missing, no missing index request doesn’t mean anything. That means nothing.

Nothing. Missing index requests are low level garbage. Low level garbage. Um. So what I would do is pay very careful attention to, um, a couple things. One.

Modification queries that hit that table. Probably that have a where clause. So like an update with a where clause or a delete with a where clause. Uh. And make sure that you have indexes that support seeks for your updates and deletes. The other thing that I would do is.

Um. Make sure that. If I am modifying that table, I’m not doing so in gigantic chunks like, you know, 100,000, 500,000, million rows plus at a time. Uh.

Uh. Because that’ll certainly lead to way more lock escalation attempts. So when I see a lot of lock escalation attempts, I can, I can tell that either you’re doing very, very big modifications to the query and SQL Server is attempting to lock the table rather than take row or page level locks. And that usually happens either when modification queries need to have a where clause or something where they need to find data.

And they don’t have an efficient way to find that data or where you’re just saying update. Hey, most of this table will do something crazy. And, and you end up trying to update like a bunch of RC lock escalation happens. To simplify this a bunch.

SQL Server will attempt to. To escalate locks when it hits around 5,000 row or page locks. And it’ll attempt to escalate row or page locks up to a table level lock. It doesn’t go row page table. It just goes row table or page table. So I can tell that either. You don’t have the right indexes, which is why SQL Server can’t find exactly what it needs to lock.

So for example, it might say, well, I was going to take a bunch of these row locks, but I can’t because I can’t find rows. And say I’ll just lock a bunch of these pages and then it ends up just saying, oh, we need way too many pages here. Let’s go for the table.

So that, that definitely happens when either you’re doing big modifications. And let me go grab my, probably the most, I wish I had a tracker on how many, how many times I’ve sent people this link. But let me paste into chat a link from Mr. Michael J. Swart, my favorite Canadian about batching modifications.

Well worth a read. Well worth modeling code after. I think, anyway. I mean, again, who am I to judge?

But yeah, those are the things that I would look for. I’ve noticed, perhaps anecdotally, that modification queries are less prone to register missing index requests. For reasons that I’m not quite sure of.

I’m not sure if it’s because a lot of modification queries end up doing eager spool work at some point, or if there’s something built in, built in that makes them less prone to getting missing index requests. I just feel like something terrible has to be going on for a SQL Server to be like, yeah, we need an index to help this, this modification. Because I don’t think, because missing index requests don’t care about, about locks.

Missing index requests aren’t there to help you resolve locking problems. They might just sort of, you know, by nature of offering a half decent index suggestion end up solving a locking problem. But the goal of a missing index request is not to resolve locking.

It is to resolve where clauses and key lookups. Because every missing index request I see is a haphazard spray of columns from the where clause in the keys. And then join and selected columns in the includes.

So, you know, perhaps not ideal for most people or workloads or figuring out why you’re hitting locks or blocks or deadlocks or any of that good stuff. A lot of crazy gutches with those missing index requests. Almost enough to make you wonder.

Makes a fellow wonder. Gets the noggin joggin at full sprint. What the code looks like in Azure or Azure, Azure, to generate the A-B testing of indexes. I’d be curious about that.

Justin says, funny enough, the name of my troubled index is missing index 208. So it sounds like someone used the database tuning advisor to do that, maybe. Unless 2087048 is a bug ticket number or a really terribly formatted and confusing date in the future.

Is the zeroth month of 2087 the 48th day or something? I don’t know. I don’t know.

I don’t know. I don’t know what will happen. It’s crazy out there. Crazy. Oh my God. We have. Okay, cool. No, we don’t have a question. We don’t have a question there.

Fun stuff. It says, when you’re not fixing SQL servers, what else do you get up to? Boy. Anyway, let’s see. I go to the gym.

And I participate in barbell training because it, it, it appeals to, it appeals to me because it’s not cardio. That’s, that’s, that’s up there. And, uh, I do that four or five days a week, kind of depending on my schedule.

Uh, and then aside from that, I’m mostly a, I don’t know. I would, I don’t want to say home body cause I’m not like just sitting home a lot. My family body though, drag my family places, make them eat things.

I like going to restaurants. Restaurants are nice. People make food for you and you eat it and then you leave and you don’t have to clean anything or anything like that. It’s a wonderful, wonderful idea for an exchange of currency.

Food for money. I like it. Prepared food for money too. Not like one of those garbage delivery services where they’re like, cook your own food. We’ll give you chicken. And you’re like, I don’t need that. I don’t know. That’s about it.

Occasionally go to a movie. I hate, I’ve hated every movie that I’ve seen recently though. Hated every movie that I’ve seen recently. Hated TV recently too. Game of Thrones last season was. Then Avengers was.

Like, like, like it was almost like, like Hollywood was like, all right, we have two big franchises ending. Let’s pit them against each other to see who can come up with the worst ending. And they both lost.

Dismal dismal. The only thing. The only thing. The only thing I’ve liked. He’s only is season 10 of Masterchef. It’s the best thing on television right now. Best thing on television. I don’t know.

Sabrina’s a bum out. Umbrella Academy was pretty good. I just want every show to be the X-Files again. So I ended up watching the X-Files. I’ve been rewatching Archer.

I’m telling you about things you didn’t ask about. I’m sorry. It’s been like, it’s been an hour now. I’m boring all of you. I’m going to go open my office door. So I have air conditioning back. Thanks for hanging out and doing stuff, asking, asking great questions. You’ve been a wonderful crowd.

And I will see you next week at the same time place. Probably. Goodbye.

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.

See you there!

Live SQL Server Q&A!

ICYMI


Last week’s thrilling, stunning, flawless episode of whatever-you-wanna-call-it.

Thanks for watching!

Video Summary

In this video, I share my day-to-day struggles and the challenges of balancing work and personal life. After discussing how sleep has been elusive lately, I transition into talking about my current projects, focusing on SQL Server training materials for both beginners and advanced users. The content ranges from foundational concepts like indexes and query plans to more complex topics such as hardware optimization and query tuning techniques. I also delve into the importance of read committed snapshot isolation (RC SI) and how it can significantly improve database performance by reducing blocking issues.

Full Transcript

I’m exhausted today. Beyond compare exhausted today. Sleep has not been my friend lately. Sleep has been. Sleep has been for someone else lately. Sleep has not been for me. Wish there was a good reason for it. Just like, sleep, cared, deprived, annoyed. So everyone go home. We’re out of here. It’s okay. I’ll stick around. I’ll try to be a reasonably perky host in this podcast. It would be really nice if you two showed me who was here.

The chat would know. I can’t see who was here. I can’t see anyone’s name. So you all have to say hello in order for me to say hello to you personally. Yes, Rowdy. Yes, Rowdy. I will be perky. Just for you. You be Rowdy, I’ll be perky. That’s about the best deal we can come to. Maybe. Maybe. Maybe. No. That’d be a weird thing. Weird. I have so much stuff to write. So much stuff to write.

It’s an awful, tremendous mountain of things to write. I’m just hoping that I can get through it all. Hoping. All of it’s about SQL servers here. None of it’s about anything weird or foreign or strange. I’m not going to like start writing on Python. Your home’s sick? My goodness. How do you get sick? Are you still in Texas? Last day I heard you live in Texas. Who knows where you are now? Man about town. Man about the country. You could be in an RV.

You could be in an RV. Was you up in it. You weren’t right my arts. And right. I’m sorry. I’m sorry. I hate work, man. But you can go out here and sit there and sit there and speak down at home when you are sleeping. something you like baseball you could be a football person my docket for today consists of trying to get through writing things for clients about what’s wrong with their servers and then trying to put put more of a dent in the the training stuff that i’m trying to produce for my site i have i have a lot of stuff written i have a lot of decks made a little demos written and uh right now up to the point where uh i’m going to do the query tuning bit so i’ve done like my sort of my intro stuff let’s go read read what i’ve done uh yeah so i’ve got my intro stuff i’ve got four decks in there about uh sort of starting like throw like a beginner’s deck um i said i think it’s probably my take on how to think like the engine probably the little engine they couldn’t uh after that uh you know some intro stuff on indexes and weight stats and query plans and then there’s like a like a real i mean i’m not gonna pretend that i can i can like deep deep deep dive but there’s like stuff you should know about the optimizer without going into holy crap what’s going on like so it’s it’s it’s high level it’s it’s not not very specific uh after that we talk about hardware so we talk about all like you know we go in depth on like you know cpu memory disk uh weight stats you’ll see related to those like when things get bad bad on the server like when things start to fall apart some of that’s based on um my my server tuning pre-con material uh then we get into some weird weight stats so my weird weight stats list consists of all the stuff that people tell you you should ignore that you should not you might you might have a favorite weight stat script that lists out a bunch of you can safely ignore these don’t worry about those pal but in reality they’re terrible terrible don’t listen to people on the internet about sql server they’re all wrong after that we get get further into indexes talk about like you know your normal run of the mill rowstore indexes you’re clustered you’re not clustered uh we get into some special indexes and uh eventually i will when i feel like it this may be about when i feel like it there will be stuff on uh partitioning i’m not crazy about partitioning i’m going to explain partitioning but i’m going to compare it to one of my all-time favorite things in sql server we’ll get into that that’s going to be a top secret it’s a big secret uh and then after that’s all the query tuning stuff is going to be like the the easy medium and hard sort of leveled off stuff there so you know we’ll have to start with the easy stuff like the implicit conversions and the you know uh like you don’t have an index and sarg ability and we’ll go on to the harder harder stuff and we tackling spools and giving them noogies and all sorts of stuff that guy’s a fan yeah that sounds great i’m gonna buy that i’m gonna buy that too we’ll show anything from you and then uh eventually eventually i think after the query tuning stuff it’ll be blocking and blocking but it’s never been my favorite thing in the world never been like wow i love i love walking and walking so i’m trying to figure out how to approach that in a way that it’ll be fun because my my favorite way to approach that is is to turn on read committed snapshot isolation or snapshot isolation and i just walk away from everything but you know there’s there’s stuff that people should know about what makes walking better and what how blocky is made see alexa you should live stream yourself trying to automate stuff using power i have nothing to automate i’ve literally i wish i had something to automate i don’t have anything to automate give me something to automate my life i would love to do it i think most of the things that that i need to automate are are done for me through biological processes i go to bed i wake up things leave my body things in my body treat treat every single day all right he says i need some serious help with getting back into query tuning well uh if if you feel like you or any or other others on your staff might benefit from the trainings of a decent looking consultant i would be more than happy to uh to to yell at people about things in a nice way i’ll be more than happy to point yes this is something you should do it stuff like that that’s helpful right that’s what people want to hear about query tuning yes you should do it yes you should tune that query yes that is slow tune it make it so aaron says rcsi should be the default i agree i agree wholeheartedly rcsi should absolutely be the default it lines up much better with what people would expect from a data boss i think and uh beyond that i think that um it’s it’s unfair to throw pessimistic locking at people and expect them to not immediately go to using your lockings and get it wrong i mean morally ethically i mean if if i look hard enough i can probably even find where it’s legally wrong to do that if you need a certain type of blocking you should be investigating the necessary hints or like sp get at lock in order to in order to get the kind of locking you need the rest of us should humbly be able to live our lives without having to deal with blocking and blocking just between readers right because it’s nonsense absolute nonsense it’s been a mistake for years i can’t i can’t say it drives me nuts the number of people i’ve seen just break down because they they can’t figure out why everything is slow sometimes or usually something like that it’s it’s just locking you go look at you go look at lock weights and it’s something like like like like lock weights are you know 30 40 50 percent of server uptime and the average milliseconds per weight is like five ten fifteen twenty seconds or beyond and you’re like yeah this is the problem you found it how are we gonna fix it it’s just like our csi is just that button it’s always right there always right there every every other smart database stuff every other smart database it’s not even it’s not even like you know uh not even like like microsoft would be the outlier unlike microsoft would get made fun of for being pessimistic by default microsoft would be like welcome to the club thanks for joining so you you finally figured it out how nice it is azure sqdb is pessimistic or optimistic by default let’s see why the box product has to be done and ugly let’s see here airlock says i automated system inventory server stats but the server configurations disk space information patching completeness account permissions on the server oh wow yeah you you must have do you have a lot of servers how many servers do you do that for that’s what i’d be curious about it’s a very enterprisey thing that’s a very like i have 20 servers and i don’t feel like i feel like figuring this out i’d also be curious if you have monitoring on those servers like if you have a monitoring tool looking at those things 120 get scanned holy cow not just for sql server either oh yeah if i had 120 servers i i’d probably i’d probably buy buy a bigger stake in power cell too me with my me with my one server i don’t know that i yeah solar lens so there are like things that i wouldn’t i wouldn’t wish on people like burpees or herpes or turkey bacon that list may or may not go on and extend to certain monitors uh you know go with go with god baron said the same thing wasn’t a good estate tool out there but i do pay for monitor service century is much better than what i’d write yet century one century one is i think um if i had to pick a monitoring tool to to work with professionally century wouldn’t probably be different that would probably be that would probably be what i could with i like i like stuff about it you know it’s not perfect no monitoring tool is but i think from what i do century one gives me the best round of information gives me the best i can point and click on some stuff and get stuff done you know it’s tougher with other it’s it’s either it’s either really hard with other monitoring tools or i just i just haven’t had the the luck of clicking in the right place on the other monitoring tools sometimes i use other monitoring tools and i right click on something and i’m like oh i would love to i would love to right click here and get more information and then i right click and it’s like save as png i’m like i don’t want to save this i want to do something else with it you know dig in what is the point of you it’s ridiculous all right he says been digging into custom queries against essentially db’s lots of data in there yeah uh i wrote a custom query in a blog post um and it’s actually kind of a cool one i was i was i was rather i was rather proud of myself for writing it uh what it is it’s a query that looks uh in the century one repository for queries that have waited a long time on getting a memory grant so and then it like compares like how long the query waited to get a grant and how long it ran after it got the grant and it’s usually crazy like i found like i found some crazy stuff when i was digging through some client repos where it was like it was like 20 30 seconds to get a memory grant and this was a goddess stories of don’t man y’all need some memory i can’t sell you that but y’all need some now that i think really i should go into ram ram sales i think i would make a killing on ram sales the century db isn’t the most intuitive but it is elegant uh i don’t know that i call it elegant but uh uh yeah i think my biggest issue with it is uh like decoding some of the hashes in there like using decompress or whatever someone’s someone’s up there stealing a car or something or maybe there’s there we go but uh yeah it’s uh so like i always run into weird issues where like when i try to use decompress on like the encoded columns where like it was somebody like the value is corrupt and i’m like well no it’s not but i’m not gonna i’m not gonna keep trying here either it goes or it doesn’t i don’t know let’s see here what else do we have going on anything come in i don’t know why i always i always look to see if someone has asked me a question somewhere else like like twitter or email or whatever but no one ever does it’s time to get lonely out there but me a very lonely very very lonely i don’t know i think uh at least i hope that um is i skipped your question where’s your question oh look at that i did uh joe says would it be odd or wrong to have a table with some indexes that are page compressed some row compressed and some with no compression at all no i don’t think so uh i mean it might not be like at first glance i would i would probably be weirded out about it at first glance i’d probably like you know what happened there but there are valid reasons you know without without without digging into like the the scant fiddle that i remember about the compression documentation now there are certain there are certain values that uh like i believe it’s string value or string values date values maybe that work better with page compression and then like integer values work better with row compression and uh some indexes don’t compress well at all in fact some with some indexes if they’re if they have a lot of write activity if they have a lot of modification activity compression can actually cause uh some issue or not issues but i think compression can slow down uh modifications in some places at least you know this is going off stuff that i remember from you know a long time ago when i was messing with it don’t it’s not probably not chapter and verse correct but it’s uh it’s decent enough it’s it’s a good enough memory to uh to uh to have that in my head so groudy says the weight stats are awesome i got into time-based index usage and operations yeah well there you go yeah a lot a lot of monitoring tools collect lots of cool stuff you know um it will be be nice if you know they got some of the stuff got exposed more in the gui so that you didn’t have to go writing crazy database queries to to get it i mean i mean on the other hand it’s cool that they let you go in there let’s see uh alexis what webcam do you use i use a logitech brio uh it’s a little dusty on top right now it’s the logitech brio i like it a lot uh i don’t recommend using the microphone for it but using it uh using it for a webcam is pretty darren says do you have any methodology you follow when auditing indexing by auditing do you mean like index changes or do you mean like the current state of indexes and if indexes should be kept or dropped or modified in some way there’s a slight difference it’s like not like a well you know it’s a big difference current state yeah so i mean i love blitz index for that uh run it in mode zero if you just want kind of uh like the the important stuff on your bigger tables run it in mode four if you want absolutely everything you know i’ll go you know i’ll go through and it’s it it prioritizes stuff for you in a pretty good way it’s not perfect but it’s it’s pretty good um i think i think what i like best about it is that uh it gives you a really good view assuming that you know uh your server has been up for a little bit and assuming that you know um uh in that you’re not on a version where index rebuilds or perhaps some recent modifications have cleared out valuable usage statistics above your indexes um it gives you a really good view too if indexes are used or not right so but uh if how how much if if all indexes overlap so you know it’s important to you know make sure that if you’re going to go in and start adding indexes to help queries go faster that you’ve cleaned up some of the cruft some of the not so hot indexes in there that already exist so you know the first thing i always look at because it’s the easiest to sort of pick out and say screw this are like the unused indexes so if like you know indexes have millions of rights against them and no reads or a very low amount of reads let’s index will call that out and you can pretty safely get rid of those you know i keep everything as a like i keep a create drop script for everything so that i know um so like if i drop an index and something goes terribly wrong the table i can add that it makes back pretty easily and then uh after after that is when i look at the uh the duplicate and borderline duplicate indexes just because i i quite often find that once i get rid of uh some of the unused stuff the uh a bit a few of the more than a few of the the border the duplicates will disappear with them so i usually do the dupes and borderline dupes last because those are a little bit more work right you have to like look at the full index definition the key columns the order the included columns and then figure out if you could like work them together in some way that makes sense and that’s more brain work that’s not as easy as just saying that’s been used zero times it’s been written to 50 million times it’s got to go it’s just taking up space it’s not helping anything uh and then so like the next thing next next next trip around will be the dupes and borderline dupes and then uh you know after that after that i’ll um so like i have very mixed feelings about the missing index requests uh you know they are certainly a good sign that we could do we could have something better like we could have a we could have a helpful index on this table the number of caveats to the indexes that that get suggested are pretty big but what i’ll usually do is like you know pick some of the really high value ones in there like what’s index will give you an estimated benefit number if it’s over like five ten million then i’m like okay we’re gonna we’re gonna we’re gonna go with this and we’re gonna see what happens right because like at that point you know it’s again it’s not going to be the best most perfect wonderful index in the world but it’s going to be a good enough bridge to get us to when we can figure out what would be so like if sql server is just absolutely screaming for some index i’ll go ahead and create it just to shut it up and then you know when i like when i have a more intimate knowledge of the workload the query is running then i’ll be able to figure out what that what the better index is for that situation because i mean it’s not like the missing indexing is always wrong but it’s wrong at a good enough pace that you know i don’t buy it for everything you know like that recommends columns and like their ordinal position in the table not by like the absolute order that they should be in in the where clause uh that they’re in the where clause or like even by which one’s more selective or anything there’s a lot of like the optimizer doesn’t really take sorts into account it always seems to stick joint columns and has included columns there’s just like a lot of stuff about the missing index requests that you know they they irk you when you’ve reached a certain point of query and index tuning but up until then they the suggestions are probably better than anything you’re going to come up with just staring at the workload right they’re they’re they’re there for a reason and they’re they’re usually a good enough bridge until you can really get in and fine two things it even says in the documentation it’s not meant for fine-drain index tuning so uh you know read that carefully if you need like you know if you need like very specific advice and don’t tell anyone i said this use dta instead just don’t create every damn index it suggests dta will do a better job than the missing index requests but dta will ask for crazy banana bonkers town indexes too dta will ask for 11 indexes that are almost the same definition just flipped around a little bit with like slightly different includes or slightly different order of key columns and it’s he agrees uh but you know so it does require adult supervision it’s the suggestions are better but it still requires an adult to sit there and go through the suggestions and say yes or no to them to me dta is usually a four-letter word because i spend a lot of time cleaning up dta messes where someone was just like oh look at these hundred indexes we need those it’s just like it’s same or whatever and and and a hundred indexes get created but you know it’s it needs adult supervision like anything else it’s the the suggestions are better than the missing index request dmds but it requires just as much adult supervision as the missing index requests and says the unused is going to be helpful seems like there’s a lot of indexes that don’t have the correct leading edge column uh well you know uh again that’s that’s an intimate workload knowledge thing that is not something that i can just say yes or nothing to here uh usually think of missing indexes as a need to index here but this might not be yeah you know it’s like it like like i said about like i’ve been saying about missing indexes for a very long time is uh they’re a lot like a crying baby right like there’s a lot of reasons that a baby could be crying and it’s it’s up to you is the the hopefully sober and caring adult to figure out exactly why that baby is crying and exactly what that baby needs to stop crying you know it might be a burp it might be a dirty diaper it might be hungry it just might want to do something but might be bored babies get you know babies get bored babies get bored and cry it’s like i just want to do something else like yeah i get it baby i’m gonna do something else i mean it’s it’s up to you to kind of figure it out it’s a it’s the the crying baby of performance tuning you know something is happening over here and it’s up to us to uh figure out how to how to fix that happening it’s uh it’s interesting though like like what like one of my pet peeves with the missing index requests is that uh when sql server has a query plan with an index in it that index pool will get created and then thrown away every time the query runs but no missing index request gets generated either in the query plan or in the missing index dmds but dta will suggest a pretty decent index to cover the index missing indexes some reason they overlook that some reason i don’t know why but you know microsoft stopped responding to my phone call my emails get a lot of my emails i seem to bounce i talk about this stuff i don’t know there’s lots of stuff that i would love to make better that i would love to love to make like getting like you know actionable like more like like more actionable feedback more readily available to people but you know not everything not everything solves a big enough s.a.p customer problem so not everything gets prioritized the way that i do instead we get poly base and we get uh poly base we get python java r we get we get lots of stuff but we still have the same performance problems lots of stuff microsoft is not dancing with who they from a lot of those find that indicating protection so which is um the party says i like the dubstep remix of this episode yes so certainly a lot of noise behind this thing one of these days one of these days i will i will be a a very rich consultant who lives in a high eyes surrounded by glass where there is no environmental anything no toys no bugs no wind no heat nothing someday I’ll be there someday when I am I guess these these webcasts will be a lot quieter I don’t know I don’t know maybe maybe maybe I’ll be too rich to do maybe I’ll maybe I’ll just have an army of SQL SQL serpents I’ll just sit around eating caviar Dallas offices are cheap yes but they’re in Dallas which poses quite quite an issue for me because Dallas is too hot constantly I don’t have a car and it’s in Dallas that commute alone makes it not worthwhile anyway we’re about at the half-hour mark and I have I have a lot of stuff right so I’m gonna get going thank you for hanging out with me thanks for uh for doing this thing with me and I will talk to you next week

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.