Posts by Erik Darling

Adventures In Foreign Keys 3: Why Cascading Deletes Perform Slowly

Legendreary In the last post, I looked at some issues with implementing foreign keys with cascading actions. Namely that, well, it fell apart pretty quickly just trying to set up. I didn’t even get to the point where I wanted to test all those relationships. But there’s an even worse surprise waiting for you if…
Read More

The Curse of Cursor Options

Execution Plans
12 Comments
Red Skies At Night I know it’s hard to believe, but I still see a lot of people using cursors when they shouldn’t. Other times, there’s some scary dungeon part of the code that someone wrote eons ago that no one wants to go anywhere near to fix. Sometimes there’s a decent reason, something like:…
Read More

SUM, AVG, and arithmetic overflow

T-SQL
14 Comments
You Shoulda Brought A Bigger Int Sometimes you run a query, and everything goes fine. For a while. For example, if I run this query in the 2010 copy of Stack Overflow, it finishes pretty quickly, and without error. Transact-SQL SELECT u.Id, u.DisplayName, SUM(p.Score) AS SumPostScore, AVG(c.Score) AS SumCommentScore FROM dbo.Users AS u JOIN dbo.Posts…
Read More

Skewing Parallelism For Fun And Profit

Execution Plans
2 Comments
What Is Skewed Parallelism? When queries go parallel, some assumptions get made: There’s enough work to keep multiple threads busy Each thread will get an equal amount of work to do The ‘equal amount of work’ part is particularly important, because in a parallel plan, each thread gets an equal share of memory up front.…
Read More
Pocket Square

First Responder Kit Release: Fingers Crossed!

First Responder Kit Updates
0
This is a small release just to make sure you don’t forget about us. We know you’re busy. You can download the updated FirstResponderKit.zip here. sp_Blitz Improvements #1755 – @MisterZeus added a new check for alerts that don’t send information out. I mean, is that even an alert? #1766 – @jadarnel27 added some code to help folks who have a standard (non-sa)…
Read More

The New Lightweight Query Plan Profile Hint

Execution Plans
0
Recent Updates To SQL Server 2016 and 2017 introduced a new USE HINT that lets you direct an actual execution plan to a new Extended Event, called query_plan_profile. The hint by itself doesn’t do anything, and the XE by itself doesn’t do anything. You need to have both. Alright then, let’s do that. Sessions Assuming you’re on…
Read More

One Hundred Percent CPU

Humor
15 Comments
Raise Your Hand If You’ve ever wanted to play a prank on your co-workers, but just didn’t have a any ideas that didn’t involve exploding Hot Pockets. Now you have something even less safe than molten cheese squirts! A stored procedure that pushes CPUs to 100%. All of’em. Transact-SQL CREATE OR ALTER PROCEDURE dbo._keep_it_100 AS…
Read More

Announcing SQL Server 2019

SQL Server 2019
6 Comments
TEASE Who Let The Docs Out? Ignite must be coming up. If you head over to Microsoft’s GitHub repo, you can peruse around for stuff updated recently. Maybe you’ll create an account. Maybe you’ll start contributing to open source projects. Maybe you’ll quietly slip into a world of solitude for days on end. Happy Saturday!…
Read More