SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to find SPs with parallel plans? Really this simple?


How to find SPs with parallel plans? Really this simple?

Author
Message
DennisPost
DennisPost
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 555
Our high usage OLTP server has MAXDOP = 0 and Cost threshold = 5. (12 cores)
Top wait is CXPacket
I am wanting start tweaking this with MAXDOP = 5 and Cost threshold = 50 (Good hardware)

Looking into how many cached plans actually use parallelism, I arrived at this query.
SELECT   'Cached_Plans' QrySrc,  
DB_Name(EQP.dbid) DBName,
OBJECT_NAME(ObjectID, DBID) ObjName,
EPS.Execution_Count,
EPS.Cached_Time,
EQP.Query_Plan
FROM sys.dm_exec_cached_plans ECP
CROSS APPLY sys.dm_exec_text_query_plan(ECP.Plan_Handle,0,-1) EQP
INNER JOIN sys.dm_exec_procedure_stats EPS
ON EQP.[DBID] = EPS.Database_ID
AND EQP.ObjectID = EPS.[Object_ID]
WHERE DBID < 32767
AND EQP.Query_Plan LIKE '%Parallelism%' COLLATE SQL_Latin1_General_CP1_CI_AS


Is this query acturate? It only returns 2 from the 165 stored procedures on this server.

If this is accurate then that means that I have to review all the SPs ensuring nothing is forcing serial plans, as per Paul Whites (SQLKiwi) blog

It's Friday afternoon..... My excuse for the hastily written question. :-D
Jack Corbett
  Jack Corbett
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18542 Visits: 14898
Jonathan Kehayias has a query in this blog post that finds parallel plans in the cache so you could compare your results to his.

Oh, also, it could be that you don't really have performance issues and that CXPACKET just happens to bubble to the top because everything else is working so well. Some wait type has to be the biggest.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39982 Visits: 32653
I'd use Jonathan's query to find the plans.

Also, yours only includes procedures. It doesn't include ad hoc queries. You'd need to hit sys.dm_exec_query_stats for that.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
DennisPost
DennisPost
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 555
Thanks for help guys.

Jack Corbett (5/2/2014)
Jonathan Kehayias has a query in this blog post that finds parallel plans in the cache so you could compare your results to his.

Oh, also, it could be that you don't really have performance issues and that CXPACKET just happens to bubble to the top because everything else is working so well. Some wait type has to be the biggest.

Thanks for the link. I'll try his query when I'm back in the office.
The server I'm looking into is pretty much maxing out on CPU and I/O. There are a good many Waits that need tending to, I'm just getting started :-)

Also, yours only includes procedures. It doesn't include ad hoc queries. You'd need to hit sys.dm_exec_query_stats for that.

I did. Without the join to sys.dm_exec_procedure_stat. Same 2 procedures popped up. Nothing else.
I'll will indeed use Jonathan's query.
sqldriver
sqldriver
SSC Eights!
SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)

Group: General Forum Members
Points: 976 Visits: 2518
I've always had good luck with this query, though I've never compared the results or performance to the Jonathan Kehayias query.
DennisPost
DennisPost
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 555
Jonathans query only returns 8 queries.

OptimizationLvl SubTreeCost usecounts size_in_bytes
FULL 250.423 8 131072
FULL 11.585 4986 73728
FULL 909.892 4 73728
FULL 25.486 4 163840
FULL 112.034 24 106496
FULL 364.273 561 131072
FULL 402.357 308 229376
FULL 231.654 594 483328



Looks like I need to start tweaking.
Thinking MAXDOP 5, Threshold 10

Maybe a simple question, but how can I best measure the changes?
Can I make these changes during normal hours? (Doesn't matter if cached plans are cleared)
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39982 Visits: 32653
I'd probably bump the threshold cost up to at least 30 based on the information you have.

You can make this change right in the middle of the day. It's very unlikely to cause issues other than changing which plans run in parallel, so, for the simpler plans, you'll get a recompile.

To measure the impact, I'd focus on those two plans that have a cost of 11 and 25 (assuming you set the threshold higher). See what their execution time is before and after you change the limit. As to the others, same deal, focus on execution times. Those cost estimates are so high, I don't doubt for a minute that those plans are, in all likelihood, good candidates for parallel execution. The other two, not so much.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
sqldriver
sqldriver
SSC Eights!
SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)SSC Eights! (976 reputation)

Group: General Forum Members
Points: 976 Visits: 2518
Best practice for MAXDOP is usually set to it to the number of physical cores in a NUMA node. How did you arrive at 5? Sorry if I missed something.

When I had to tune some servers recently, I started taking measurements using this Paul Randal script and compared the waits before and after. CXPACKET went from being 25-35% of the waits to 6-7% of the waits. Now they're mostly backup IO and other background process related.

Depending on the server, MAXDOP got either 4 or 6, and I ended up setting the cost threshold for parallelism to (mostly!) 100, but one SPED server got 200 because it's running 2008R2 Standard on almost EOL hardware with 16Gb of memory and it's about to get virtualized.
DennisPost
DennisPost
SSC Veteran
SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)SSC Veteran (289 reputation)

Group: General Forum Members
Points: 289 Visits: 555
Thanks for the input guys.

Sorry for the late post back. Priorities shift a lot here.
(Haven't even starting testing backups yet! Sorry Grant. I'll get to it. I promise.)


I'd probably bump the threshold cost up to at least 30 based on the information you have.

Why is that?
To make sure the majority of the queries are single threaded and use parallel queries relatively sparingly?


Best practice for MAXDOP is usually set to it to the number of physical cores in a NUMA node. How did you arrive at 5? Sorry if I missed something.

I was thinking in the lines of being able to run 2 parallel queries and 2 serial queries simultaneouslyish.
All our machines are virtual.
Grant Fritchey
Grant Fritchey
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39982 Visits: 32653
Yeah. Those cost estimates can be quite high for fairly simple queries that won't benefit from parallelism. Bumping up the default value is one of the first things I do.

Well, that is, after I test the backups. w00t

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search