Statistics for the New Data Pro

PASS, SQL Server, SQL Server 2016, T-SQL
Next week at the PASS Summit I'll be presenting a session called Statistics for the New Data Pro. You can read the abstract at the link. I just want to emphasize that this is a beginner level session. I think way too many people who are just starting out with SQL Server don't understand the role that statistics play in determining how your queries are going to behave. What's more, too many people don't know how to get and read statistics to understand how it is that the optimizer thinks you have X number of rows in your database that match a given value. I'm going to make darned sure that the people who attend this session come out with a full understanding of how to read the statistics. This includes…
Read More

Getting Started With DocumentDB

Azure, DocumentDB
I've put this off for too long. It's time to get my feet wet with some new tech. Step 1 is easy. Go to the Azure portal and start the process for creating a DocumentDB: While that's running, let's see what's on the interwebs about getting started in DocumentDB... Nice. I know I'm going to have write a little code to exercise this thing. Here's a great run-through on exactly how to do it. Actually, the first hit when I searched on "Getting Started With DocumentDB." Microsoft has a start page on DocumentDB, but it was clearly put together by someone from marketing. Scroll down to the bottom. There are a couple of interesting links including SQL Query Within DocumentDB. Now we're talking. Here's a Curah! or Docs.com (which is…
Read More

Argenis Without Borders: Fun For a Good Cause

Misc
This is the second year of Argenis Without Borders and the second year that I'm taking part. Last year we hit the fund-raising goal and I wore the rainbow fuzzy leggings at the PASS Summit. This year, it feels like we're a little behind the goal. We need you to get your wallet and fork over a little cash to help out this worthy charity, Doctors Without Borders. This year, the goal will be to get me into a funny hat. But, well, I already wear funny hats all the time: So I'm a little at a loss as to what to do: I mean seriously, where do I go from here? Any suggestions for a good funny hat? Only make them after you've donated though.
Read More

Trace Flags in Azure SQL Database

Azure, SQL Server 2016, T-SQL
One of the ways that you take more direct control over your SQL Server instances is through the use of trace flags. There are a number that people recommend you enable by default. Prior to Extended Events for example, I'd say you should turn on trace flag 1222 in order to capture deadlock information on your server (now I just recommend you use the system_health session). I absolutely think you should turn on trace flag 2371 to get better behavior out of your automated statistics updates. There are others that I'll leave to all the systems experts to advise you on. What about Azure SQL Database? I doubt you'll be shocked, but if I try this: DBCC TRACEON (2371,-1); I get the following error: Msg 2571, Level 14, State 3,…
Read More

Speaker of the Month: October 2015

Professional Development
Working on my third year of "Speaker of the Month" posts now. The good news, I haven't run out of people to award it to. Most months, if I've been able to go to a community event or two, I have three or four candidates.  Same this month. Speaker of the Month for October 2015 is Rob Volk and his presentation, Revenge: THE SQL, at SQL Saturday Las Vegas. What can I say about this presentation? Let me start by saying that you never, ever want to make Rob angry. Next, I think Rob needs a hobby that will help him turn his mind away from EVIL. Next, Rob has to be one of the smarter people that I know. Next, Rob is very funny. Oh yeah, and there was…
Read More

PASS Nominations Committee 2015

PASS
The Nominations Committee has done their job and the final report has been published. Good luck to everyone running. Thank you for stepping up and taking part in this process. This is the first time in a very long time that I don't get to put out a "You should listen to me and vote for..." blog post. Since I'm on the board I feel more than a little squeamish coming out for any candidate. If I openly support Person Y over Person X, have I just yacked off all the supporters of Person X? Have I yacked off Person X? Most importantly, have I potentially poisoned a relationship that I need in order to be effective while on the Board? Add to that the fact that I was ask…
Read More

Yes, Foreign Keys Help Performance

SQL Server
I created this example several years ago that illustrates how foreign key constraints can help performance. It's a contrived example. Granted. I feel like it illustrates the point. However, over the years, people have questioned one aspect of it. The optimizer uses the foreign keys to figure out which tables can be eliminated from the query, making for a more efficient plan and making the query run faster. The pushback has always been, "Yeah, Grant, but nobody writes T-SQL where they include extra tables that they don't need." My initial response, after I stop laughing, is to point out any number of ORM tools. But, you know what, let's assume that's correct. No one would ever create a giant catch-all view that has all their JOINs in one place so they don't have…
Read More

Speaker of the Month: September 2015

Professional Development
Feast or famine. The last several months I just haven't seen that many speakers, let alone that many community speakers. Then, in the last month, I've seen a ton. Contests being what they are though, someone has to win. To everyone I saw speak at SQL Saturday Oklahoma City and SQL Saturday Omaha who doesn't see their name here, apologies. I saw great presentations this month. The winner though is Ryan Adams (b|t) and his presentation: Backup and Restore Tips and Tricks. Ryan started off great, walking around the room, looking people in the eye has he talked and using the slides as a guide, not reading from them at all. He had a bunch of slides that visualized different aspects of backup and restore. I really loved the one…
Read More

Targeted Plan Cache Removal

Azure, T-SQL
A lot of times you'll hear how people are experiencing sudden, intermittent, poor performance on a query, bad parameter sniffing at work, so they'll fix it by running the following code: DBCC FREEPROCCACHE(); BOOM! Yeah, you just nuked the cache on your server because you wanted to take out a single terrorist query. Now, yes, that problematic query is going to recompile and hopefully have a better execution plan. Also, so are all the other queries on your system. That spike in CPU and the slow-down all your business people are experiencing... Your fault for going nuclear. Instead of a nuke, why not use a sniper rifle to just remove the one problematic plan. Here's a little piece of code to help out: DECLARE @PlanHandle VARBINARY(64); SELECT @PlanHandle = deps.plan_handle FROM…
Read More

Time to Change

Database Lifecycle Management
I recently spent two days consulting with a company on their database development and deployment processes. They are a small, capable, team of developers, database developers and a DBA who have embraced the idea that they need to be able to automate their deployments. I wasn't in there to teach them much of anything, but to help walk them through what the possibilities were for their deployments. It was a great experience and I learned a lot. They recognized that it was time to change what they did and how they did it in order to achieve greater efficiencies. They recognized that, while they were successfully building and deploying their databases (a capable team, remember), they were experiencing pain that they could alleviate. Like Peter, it was a time for change. I…
Read More