SQL Server Automatic Tuning and sys.dm_db_tuning_recommendations

Azure, SQL Server 2017
In Azure SQL Database for quite some time and now available in SQL Server 2017, Microsoft has put a lot of the knowledge they've gleaned from running more databases that any of the rest of us ever will to work with Automatic Tuning. Automatic Tuning The core of automatic tuning at this point in time (because I'm sure it's going to evolve) is the ability of the query engine to spot when a query has generated a new plan and that new plan is causing performance to degrade. This is known as a regression in the plan. It comes from bad parameter sniffing, changes in statistics, cumulative updates, or the big notorious one, the cardinality estimator introduced in SQL Server 2014 (it's been almost four years, I'm not calling it…
Read More

Query Store Wait Statistics with sys.query_store_wait_stats

Azure, SQL Server 2017
The second best thing to questions that people ask is when I sit down to write a book. It's so easy to miss things in the day-to-day grind of doing work. Then, late at night, you're working on a chapter, so you read up on the documentation to ensure that you're not missing anything. Of course, then you find, yes, you are missing something. In my case, sys.query_store_wait_stats. sys.query_store_wait_stats. If you follow the link above, it'll give you what you need to know, but, I figured I'd provide a little more clarity because I think there are some pitfalls in using this data. I love Query Store (do a search to see all the exploration I've done with it). One of my favorite things is the time intervals. It breaks…
Read More

Execution Plan Metrics and Units of Measure

SQL Server, SQL Server 2016, SQL Server 2017
Have you ever looked at the properties inside an execution plan and wondered what the units of measure were? I know I have. I also get the question pretty frequently about all sorts of properties. What does EstimatedAvailableMemoryGrant display it's units in anyway? For that matter, what the heck is an EstimatedAvailableMemoryGrant? Showplan Schema and Units of Measure The answer to those questions and a whole lot more is pretty easy to find. You just have to look to the ShowPlan Schema. Microsoft has all the schema's published, going back to 2005. The next time you're faced with a question such as, what are the units of measure of the MemoryGrantInfo: Or, what the heck is SerialDesiredMemory and why is it exactly matching RequestedMemory, you just have to go and…
Read More

SQL in the City 2017

Redgate Software
Redgate is once again hosting a live, virtual event for SQL in the City. We're going to give you a lot of educational content on DevOps, SQL Server, Monitoring, GDPR and compliance. We'll also be doing all this with Redgate tools. Here's my promotional video for the event: [video width="1280" height="720" mp4="https://www.scarydba.com/wp-content/uploads/2017/12/SitC.mp4"][/video] I hope you'll join us for this event. It's live, so you can ask questions and we'll all try to help out. Go here to register.
Read More

Why I Use AdventureWorks for Demos

SQL Server, SQL Server 2016, SQL Server 2017
I know that when some people see AdventureWorks, their vision turns all red around the edges, their blood pressure spikes and they begin to foam at the mouth. I do understand. AdventureWorks, Microsoft's very old, near ubiquitous, sample database suffers from a lot off issues. What's The Matter With AdventureWorks? Let's start off with the general design of the schemas. It's broken up in odd ways. Production has a TransactionHistory and a TransactionHistoryArchive instead of Sales? That doesn't make any sense. What the heck is up with the general database design anyway? I mean, pick on one example. A person can have more than one phone number. Fine. But, what about people who share phone numbers like that ancient land line in my house that is only EVER used by…
Read More

Automating T-SQL Code Analysis

Redgate Software
With all the options available within T-SQL these days, it's more and more imperative that our code be clear and consistent. For example, there are clustered indexes and nonclustered indexes. Oh, but those are rowstore indexes. You also have clustered columnstore and nonclustered columnstore indexes. When you write T-SQL that says "CREATE INDEX MakeMyQueriesFast ON dbo.MySlowTable" which one do you mean? Well, the default there will be a nonclustered rowstore index. How do I know that? I checked the documentation. Oh, same thing will work with a columnstore index. You don't have to specify that it's nonclustered, but doesn't that seem unclear to you? It does to me. Clarity and Understanding You can write T-SQL a bunch of ways. Further, you can do some pretty crazy stuff with it that…
Read More

Database Fundamentals #15: Modifying Data With T-SQL

Database Fundamentals, SQL Server, SQL Server 2016, SQL Server 2017
The preferred method for modifying your data within a database is T-SQL. While the last Fundamentals post showed how to use the GUI to get that done, it's not a very efficient mechanism. T-SQL is efficient. UPDATE The command for updating information in your tables is UPDATE. This command doesn’t work the same way as the INSERT statement. Instead of listing all the columns that are required, meaning columns that don’t allow for NULL values, you can pick and choose the individual columns that you want to update. The operation over-writes the information that was stored in the column with new information. In addition to defining the table and columns you want to update, you have to tell SQL Server which rows you’re interested in updating. This introduces the WHERE…
Read More

I May Never Be a Data Scientist

Data Science
Chances are extremely high that I'll never put down Data Scientist as my job. Considering what you do and what you know, I'll bet a healthy percentage of you are in a similar situation. That's OK. You know why? You know a lot about data, data movement and data processing that a Data Scientist doesn't. They Also Serve I don't know about you, but I'm not standing around waiting to serve. Instead, I'd be actively chasing after any and all Data Scientists within my organization offering to serve. If you can't be the Data Scientist who do you want to be? The Data Scientist's go-to technician. That's me handing over a new data set to the Data Scientist I'm working with: OK, really it's the best James Bond and the…
Read More

Get That Profiler Feel in Extended Events

SQL Server, SQL Server 2016, SQL Server 2017
I know. You love Profiler. I hear you. You're wrong, but that's OK. Kidding... mostly. Unfortunately though, I think a lot of what passes for issues and problems with Extended Events is actually a lack of knowledge about how they work. Let's take an example and run with it. No Grid in Extended Events One of the pushbacks I hear about using Extended Events is that the Live Data GUI just doesn't have that neat Profiler grid output. Instead you see a list of events in the top pane and then you have to look at the details in the bottom pane. It looks like this out of the gate: You're right. That's a royal pain. That's it. Toss Extended Events. Back to Profiler. Well, hang on a second. Let's…
Read More

Presenting Azure Vs. Working With Azure

Azure
I have a real infatuation with Azure. I'm especially interested in the Platform as a Service (PaaS) offerings in and around the Data Platform. I truly believe that these are the subversive elements that are going to change how a lot of us get our jobs done with data. I've worked with Azure SQL Database within my organization and I do lots of experimentation and testing. Any chance I get, I like to present sessions on Azure. Funny thing though, my presentations are never as easy as work, and I think I ought to discuss why. Connectivity, Connectivity, Connectivity In case you can't tell, I'm starting off talking about connectivity. However, this is an important topic. When I'm working on Azure, I'm usually hooked up to my home office or…
Read More