Stored Procedures Are Not Faster Than Views

SQL Server, SQL Server 2016, T-SQL
A performance tuning tip I saw recently said, "Views don't perform as well as stored procedures." <sigh> Let's break this down, just a little. Definitions A view is nothing but a query. The definition given by Microsoft is that it's a virtual table that's defined by a query. It's a query that is used to mask data or perform a complex join or similar behaviors. Views are queries that get stored in the database. Views can be easily referred to as if they were a tables. That's it. I've written in the past about views, including how they can possibly perform poorly. A stored procedure is also a query, or a series of queries, or, a whole lot more. Microsoft's definition of a stored procedure basically defines it as programming object that can accept input through…
Read More

A Sub-Query Does Not Hurt Performance

SQL Server, SQL Server 2016, T-SQL
The things you read on the internet, for example, "don't use a sub-query because that hurts performance." Truly? Where do people get these things? Let's Test It I've written before about the concept of cargo cult data professionals. They see one issue, one time, and consequently extrapolate that to all issues, all the time. It's the best explanation I have for why someone would suggest that a sub-query is flat out wrong and will hurt performance. Let me put a caveat up front (which I will reiterate in the conclusion, just so we're clear), there's nothing magically good about sub-queries just like there is nothing magically evil about sub-queries. You can absolutely write a sub-query that performs horribly, does horrible things, runs badly, and therefore absolutely screws up your system. Just as…
Read More

SQL Cruise as a Speaker and Sponsor

Professional Development
SQL Cruise offers a number of unique opportunities for everyone involved, including speakers and sponsors. I've written before, several times, about the benefits of SQL Cruise. As an attendee of the cruise, you will get to sit in classes by amazing people (and me) talking about all aspects of the Data Platform. Further, you get the opportunity to sit down, for long hours, with these people and get, for want of a better description, free consulting time. What about as a speaker and a sponsor though, do we get benefits? As A Speaker Tim Ford is quite a bright fellow. He has tweaked and tuned SQL Cruise. I have been on SQL Cruise a number of times over the last five years, and it has changed radically since my first cruise…
Read More

SELECT * Does Not Hurt Performance

SQL Server, SQL Server 2016, T-SQL
I read all the time how SELECT * hurts performance. I even see where people have said that you just have to supply a column list instead of SELECT * to get a performance improvement. Let's test it, because I think this is bunkum. The Test I have here two queries: SELECT * FROM Warehouse.StockItemTransactions AS sit; --and SELECT sit.StockItemTransactionID, sit.StockItemID, sit.TransactionTypeID, sit.CustomerID, sit.InvoiceID, sit.SupplierID, sit.PurchaseOrderID, sit.TransactionOccurredWhen, sit.Quantity, sit.LastEditedBy, sit.LastEditedWhen FROM Warehouse.StockItemTransactions AS sit; I'm basically going to run this a few hundred times each from PowerShell. I'll capture the executions using Extended Events and we'll aggregate the results. The Results I ran the test multiple times because, funny enough, I kept seeing some disparity in the results. One test would show a clear bias for one method, another test would…
Read More

Pre-Summit PASS Board Update

PASS
Busy, busy, busy. A lot of the work around PASS currently is getting ready for Summit. I'm prepping my part in the keynotes. I'm involved in lots of community discussions including SQLSaturday, Chapters and Regional Mentors. We're setting up the Community Zone for all sorts of activities throughout the week. We're also going to have one of our few in-person board meetings at Summit. Putting on the single largest gathering of data professionals around the Microsoft Data Platform is actually labor-intensive. The majority of the work is done by the amazing individuals at Christianson & Company, but the board is involved in the necessary decisions and, being the guy who handles finance, I'm in on a lot of those decisions. Personally, I think we're putting together, say it with me, THE BEST SUMMIT EVER.…
Read More

Statistics Are Vital For Query Performance

SQL Server, SQL Server 2016
This is post #10 supporting  Tim Ford’s (b|t) initiative on #iwanttohelp, #entrylevel. Read about it here. When you send a query to your SQL Server database (and this applies to Azure SQL Database, APS, and Azure SQL Data Warehouse), that query is going to go through a process known as query optimization. The query optimization process figures out if you can use indexes to assist the query, whether or not it can seek against those indexes or has to use a scan, and a whole bunch of other stuff. The primary driving force in making these decisions are the statistics available on the indexes and on your tables. What Are Statistics Statistics are a mathematical construct to represent the data in your tables. Instead of scanning through the data each and every…
Read More

Where Do We Go To Share?

Misc
No one reads blogs any more. Twitter is dying. Facebook is broken. LinkedIn? Please. G+. Is that even on any more? Where do we go to share? I'm seeing it here on this blog. Traffic is down. Not just day-to-day traffic, but the search hits. That could just be that I'm producing crap content or stuff that no one is interested in. However, Twitter isn't growing like it once was and there are many reports that it's shrinking. Facebook is running into problems. So... Where the heck are people going? How do we continue to share without a relatively common communication tool? I know there's some push for Yammer. However, lots of people hate it. Slack and slack channels get a little traction, but to a degree this is just another type of…
Read More

Correlated Datetime Columns

SQL Server, SQL Server 2016, T-SQL
SQL Server is a deep and complex product. There's always more to learn. For example, I had never heard of Correlated Datetime Columns. They were evidently introduced as a database option in SQL Server 2005 to help support data warehousing style queries (frequently using dates and times as join criteria or filter criteria). You can read up on the concept here from this older article from 2008 on MSDN. However, doing a search online I didn't find much else explaining how this  stuff worked (one article here, that didn't break this down in a way I could easily understand). Time for me to get my learn on. The concept is simple, turning this on for your database means that dates which have a relationship, the example from MSDN uses OrderDate and…
Read More

Azure Data Platform Resources

Azure
A few months ago I created a GitHub repository for the purpose of building and maintaining a list of resources for Azure Data Platform training. You can see it here. My goal in putting this into GitHub instead of just running it on my blog is to make it a community resource. I want all of you to maintain it. If you're teaching a class (one hour or one week, I don't care), I'd like you to add yourself to the instructors list. If you have a blog where you post Azure content, please, add your blog. Are you a PowerBI monster? Get on the list. Please, help me create and grow this list so that people have a central, public, resource for this information. More and more of you are…
Read More

Volunteering With PASS

PASS
I was just asked how many times I've been to the PASS Summit. This year will be my 12th consecutive one. That made me start thinking. At my very first Summit, I met a couple of volunteers for PASS (Allen Kinsel was one of them, I'll blame him forever). They were having so much fun that I decided to volunteer. I've been volunteering now for eleven years. I couldn't stop. Here's what I've done over the years at PASS: Book Review Committee (my first PASS "job") Editorial Committee (I wrote stuff) Editor of the SQL Standard (I had other people write stuff) First-timer Mentor (I wasn't very good at this one) First-timer Event... Chair? (I got up in front of the room, this one might not count) Founder of SQL Kilt Day (and…
Read More