Launch week: the Season Pass & Fundamentals Week are 50% off — ends in 9d 09h 46mSee the sale

Category: Memory Grants

Performance Tuning

Parameter Sniffing in SQL Server 2019: Air_Quote_Actual Plans

My last post talked about how parameter sniffing caused 3 problems for a query, and how SQL Server 2019 fixes one of them - kinda - with adaptive memory grants.

However, the post finished up by talking about how much harder performance troubleshooting will be on 2019 because your query's memory grant is based on the last set of parameters used, not the current set.

Read more about Parameter Sniffing in SQL Server 2019: Air_Quote_Actual Plans Be the first to comment
Performance Tuning

Parameter Sniffing in SQL Server 2019: Adaptive Memory Grants

This week, I'm demoing SQL Server 2019 features that I'm really excited about, and they all center around a theme we all know and love: parameter sniffing.

If you haven't seen me talk about parameter sniffing before, you'll probably wanna start with this session from SQLDay in Poland. This week, I'm going to be using the queries & discussion from that session as a starting point.

Read more about Parameter Sniffing in SQL Server 2019: Adaptive Memory Grants 18 comments — Join the discussion
Performance Tuning

What’s New in SQL Server 2019: Adaptive Memory Grants

When you run a query, SQL Server guesses how much memory you're going to need for things like sorts and joins. As your query starts, it gets an allocation of workspace memory, then starts work. Sometimes SQL Server underestimates the work you're about to do, and doesn't grant you enough memory. Say you're working with…

Read more about What’s New in SQL Server 2019: Adaptive Memory Grants 3 comments — Join the discussion
T-SQL & Development

Concurrency Week: How Entity Framework and NHibernate Can Cause Poison RESOURCE_SEMAPHORE Waits

I've already blogged about my dislike for ORMs from a production DBA performance tuning standpoint only. I get that they're useful to developers. I get it. But I'm focused on performance.

A quick recap of what I don't like about ORMs from that other blog post:

Read more about Concurrency Week: How Entity Framework and NHibernate Can Cause Poison RESOURCE_SEMAPHORE Waits 6 comments — Join the discussion
Performance Tuning

Hash Join Memory Grant Factors

Buskets
Much like Sorts, Hash Joins require some amount of memory to operate efficiently  -- without spilling, or spilling too much.

And to a similar degree, the number of rows and columns passed to the Hashing operator matter where the memory grant is concerned. This doesn't mean Hashing is bad, but you may need to take some extra steps when tuning queries that use them.

Read more about Hash Join Memory Grant Factors 8 comments — Join the discussion
Performance Tuning

Memory Grants: SQL Server’s Other Public Toilet

Sharing Is Caring
When everything is going well, and queries are behaving responsibly, one need hardly think about memory grants.

The problem becomes itself when queries start to over and under estimate their practical needs.
Second Hand Emotion
Queries ask for memory to do stuff. Memory is a shared resource.

Read more about Memory Grants: SQL Server’s Other Public Toilet 13 comments — Join the discussion
T-SQL & Development

“But It Worked in Development!” – 3 Hard Performance Problems

You've been performance tuning queries and indexes for a few years, but lately, you've been running into problems you can't explain. Could it be RESOURCE_SEMAPHORE, THREADPOOL, or lock escalation? These problems only pop up under heavy load or concurrency, so they're very hard to detect in a development environment. In a very fast-paced session, I'll…

Read more about “But It Worked in Development!” – 3 Hard Performance Problems Be the first to comment
Performance Tuning

SQL Server 2017 CU3 adds tempdb spill diagnostics in DMVs and Extended Events

Where have you been all my life?
Whenever I'm teaching people about query tuning, two things come up almost without fail: parameter sniffing and tempdb spills.

They're not mutually exclusive -- some queries will seemingly always spill to tempdb, whether parameter sniffing is present of not, and some queries experiencing issues with parameter sniffing will never spill to tempdb.

Read more about SQL Server 2017 CU3 adds tempdb spill diagnostics in DMVs and Extended Events 4 comments — Join the discussion
Performance Tuning

What’s the Difference Between Estimated and Actual Execution Plans?

I'm going to use the dbo.Users table in the StackOverflow demo database and run a pretty simple query: [crayon-6a452065829d7233591243/] First, hit Control-L in SSMS and get the estimated execution plan. Here it is: Click on the plan, and hover your mouse over the various operators. You'll notice that almost all of the fields are prefixed…

Read more about What’s the Difference Between Estimated and Actual Execution Plans? 2 comments — Join the discussion
Performance Tuning

An Introduction to Query Memory

Microsoft has been quietly making some amazing improvements for performance tuners in SQL Server 2012, 2014, and 2016. This week, we're going to introduce you to just how awesome they are. (They being the improvements, not Microsoft. You already knew they were awesome.)

Using the freely available StackOverflow database, let's start with a simple query - SELECT * FROM Users:

Read more about An Introduction to Query Memory 9 comments — Join the discussion

SQL Server 2012 SP3 Adds Memory Grant and Performance Features

SQL Server 2012 SP3 has just been freshly released! Not only does this release contain bug fixes, it also contains a slew of performance tuning related features.

Many of these features are about memory grants. This is NOT the memory used in the buffer pool/ data cache by the query -- it's the memory also known as Query Workspace Memory. Start reading more here.

Read more about SQL Server 2012 SP3 Adds Memory Grant and Performance Features 9 comments — Join the discussion