In the Kitchen With The Viking DBA
In the Kitchen with The Viking DBA
Fuel your body and your databases.
In today's post we're talking about one of my favorite things to do in the world; EAT! If you see me in person, you might think "He's fairly fit, but clearly never says no to a cookie." Tis true. Sweets of all sorts are an Achilles heel of mine. Though I do attempt to limit those to special occasions and I have drastically cut down on the amount.
About 2 years ago while training for my first Hyrox competition, our trainer put me on to a meal plan. this meal plan included things such as vegetables. Now again, if you know me, you'll agree that me and vegetables for a long time had a rule. We don't mess with each other. However, once I learned how to cook them to my tastes, I now find that I *gasp* enjoy them! I was 47 years old before I let broccoli pass my lips!
Well, today's post is about proper fuel. Both for your body and your database. I believe we can agree that in both scenarios, if you don't fuel properly the results are less than optimal.
Well, today's post is about proper fuel. Both for your body and your database. I believe we can agree that in both scenarios, if you don't fuel properly the results are less than optimal.
In one of my early posts, I believe I mentioned that by and large (not a rule, but mostly) us in the IT field tend to skew on the larger side and that part of my reason for this blog/video journey was to combat that. The above picture comes to mind when I think about the correlation between our careers and food. If you haven't seen that episode of The Simpsons, Homer begins working at home, albeit intentionally putting on weight so he can garner disability. He goes shopping for new clothes and this is the exchange between him and the clerk.
This hits all too hard for folks I think. It's easy to be consumed by coding, scripting, installing, monitoring and the like and just not take time to cook up something healthy. Fast food, candy, calorie laden sodas and snack chips became the staple at our desks. They're quick and easy but incredibly detrimental to overall health.
In much the same way, if you feed your SQL Server a diet of "junk food", it's going to become unhealthy. So what does that look like?
If you want your database server to perform like a metaphorical athlete, give it the proper fuel! I would say let's start with hardware, however in the modern era (while still very important), it's a little bit easier to handle. When I first started building servers in the late 90's, we had to be very careful about what we purchased. Was it going to be sized appropriately, could it grow, what kind of processor, RAM, bus speed and on and on. Granted it's been a long time since I had to hardware spec a server for SQL, but I feel that between virtual machines and cloud based hosting, it's been made easier to adjust your hardware on the fly. Heck, just today I needed more processor power in a server and with the stroke of a few keys from our Infrastructure team, it was done! I've briefly tinkered with Azure and it's all sliders. Need more RAM, sliiiiiiiiide to the right. Don't need that much any more? Slide it back. Where's that Easy button?
This hits all too hard for folks I think. It's easy to be consumed by coding, scripting, installing, monitoring and the like and just not take time to cook up something healthy. Fast food, candy, calorie laden sodas and snack chips became the staple at our desks. They're quick and easy but incredibly detrimental to overall health.
If you want your database server to perform like a metaphorical athlete, give it the proper fuel!
So hardware aside, how do you feed your SQL Server healthy fuel? A topic near and dear to my heart is indexes. Indexes are superb! Until they're not. Have you ever checked a table and found just a glut of indexes? How about when you find multiple non-clustered indexes that are using the Primary key field as the leading key? Yup, I've got some of those. And they make me cry. However it's a massive table and difficult to schedule the time to fix that.
Indexes are by and large easy. Even the execution plans will give you a handy dandy recommendation that you can go ahead and implement right from there. Nevermind that it may not be the best one or the columns suggested in the wrong order. Be honest, we've all probably done it at least once. I sure did early on. But what happens when you start adding too many? You've fed your database Little Debbie Snack Cakes and cans of coke. That table becomes bloated. Sure some of your SELECT queries get results quick. How's your disk space holding up? How about write operations? Just because you can doesn't mean you should. That Snickers bar will satisfy your hunger for now, but is that the right choice? Similarly, that new index gets what you need now, but consider the long term effects and find a better solution.
Here's another analogy. Backups, the meal prep of our SQL world. In meal prepping, we cook up a larger amount of food and then portion that out into storage containers to snag when we need a meal. It takes time on the front end, but future you will be happy you did it. It saves you time and worry about what you're going to eat.
Now consider your backup strategy. It takes some time on the front side, but it saves your worry and headache down the road. Not only from a disaster recovery standpoint, but also in keeping your log file clean. I'm sure dear reader you know this already but just in case, log files in SQL Server are capped at 2 TB. You hit that mark and your database is hard down until you shrink it. Oh and as a side note, that gets real fun when that database is participating in an Availability Group or mirror. Point being, meal prep your backups. Take the time to set them up properly and ensure they're working.
Now consider your backup strategy. It takes some time on the front side, but it saves your worry and headache down the road. Not only from a disaster recovery standpoint, but also in keeping your log file clean. I'm sure dear reader you know this already but just in case, log files in SQL Server are capped at 2 TB. You hit that mark and your database is hard down until you shrink it. Oh and as a side note, that gets real fun when that database is participating in an Availability Group or mirror. Point being, meal prep your backups. Take the time to set them up properly and ensure they're working.
Lastly I'll touch on this. Your server configuration. There are so many options available to you when installing SQL Server. MAXDOP, max memory allocation, query store, cost threshold for parallelism and the list will go on and on. Blindly accepting the defaults will allow your server to run, but will it be the best? Research some of these config settings and find out what works for your environment.
The Final Bite
I want the best for your health and the health of your SQL Servers. It's exceedingly easy to take the shortcuts, consume junk food and continue along. Down the road though, bad habits will catch you. Diabetes, heart conditions, cholesterol lurk inside every poor eating decision. I challenge you to find some recipes that are beneficial to your goals. Just like you want your servers to maintain their health and keep running optimally, so should you for your body.
If you're interested in seeing me make the plate of food in the graphic, check out my new YouTube channel! https://www.youtube.com/@TheVikingDBA
Comments
Post a Comment