Posts by Brent Ozar

When Do I Need to Use DESC in Indexes?

If I take the Users table from any Stack Overflow database, put an index on Reputation, and write a query to find the top 100 users sorted by reputation, descending: CREATE INDEX Reputation ON dbo.Users (Reputation); SELECT TOP 100 * FROM dbo.Users ORDER BY Reputation DESC; 12345 CREATE INDEX Reputation ON dbo.Users (Reputation); SELECT TOP 100…
Read More

What It Takes To Write Two Blog Posts

This week, I published two blog posts: How Bad Statistics Cause Bad SQL Server Query Performance How Scalar User-Defined Functions Slow Down Queries Let’s talk about the process of writing ’em. A couple I was putting together this week’s First Responder Kit release, I realized sp_BlitzIndex didn’t have URLs for a couple of common families…
Read More

When You’re Troubleshooting Blocking, Look at Query #2, Too.

When I’m troubleshooting a blocking emergency, the culprit is usually the query at the head of a blocking chain. Somebody did something ill-advised like starting a transaction and then locking a whole bunch of tables. But sometimes, the lead blocker isn’t the real problem. It’s query #2. Here’s a sample scenario: A long-running select with…
Read More

How Scalar User-Defined Functions Slow Down Queries

When your query has a scalar user-defined function in it, SQL Server may not parallelize it and may hide the work that it’s doing in your execution plan. To show it, I’ll run a simple query against the Users table in the Stack Overflow database. SELECT TOP 100 DisplayName, Location, Reputation, Id FROM dbo.Users ORDER…
Read More

Paul White Explains Temp Table Caching 3 Ways

1 Comment
Paul White, Debugger of SQL Server Paul White (Blog, @SQL_Kiwi) is a legendary SQL Server blogger who’s written a ton of good material. You should read all of it. You won’t, and I can say that with authority because…I don’t read it all either. It’s too much. But when your job eventually requires you to…
Read More

Why Full Text’s CONTAINS Queries Are So Slow

SQL Server’s full text search is amazing. Well, it amazes me at least – it has so many cool capabilities: looking for prefixes, words near each other, different verb tenses, and even thesaurus searches. However, that’s not how I see most people using it: I’ve seen so many shops using it for matching specific strings,…
Read More

How to Learn SQL Server in One Year

You’ve been using Microsoft SQL Server for a few years, and it’s becoming increasingly important to your job. You can write a query, but… You feel like something’s missing. You attended a few local user groups or meetups before the quarantines hit, but you were disappointed at how scattered the sessions were. The material was…
Read More