Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

How to find SPs with parallel plans? Really this simple? Expand / Collapse
Author
Message
Posted Friday, May 2, 2014 9:17 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 3:39 AM
Points: 52, Visits: 244
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.
Post #1567080
Posted Friday, May 2, 2014 10:28 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 1:42 PM
Points: 10,340, Visits: 13,341
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

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
Post #1567112
Posted Saturday, May 3, 2014 4:21 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 14,000, Visits: 28,380
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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1567244
Posted Saturday, May 3, 2014 6:15 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 3:39 AM
Points: 52, Visits: 244
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.

Post #1567257
Posted Thursday, May 8, 2014 3:02 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 4:53 PM
Points: 488, Visits: 1,983
I've always had good luck with this query, though I've never compared the results or performance to the Jonathan Kehayias query.
Post #1569093
Posted Friday, May 9, 2014 2:35 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 3:39 AM
Points: 52, Visits: 244
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)
Post #1569176
Posted Friday, May 9, 2014 6:35 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 14,000, Visits: 28,380
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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1569233
Posted Friday, May 9, 2014 7:37 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 4:53 PM
Points: 488, Visits: 1,983
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.

Post #1569264
Posted Friday, June 13, 2014 8:55 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 4, 2014 3:39 AM
Points: 52, Visits: 244
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.
Post #1580569
Posted Friday, June 13, 2014 10:19 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:26 AM
Points: 14,000, Visits: 28,380
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.


----------------------------------------------------
"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
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1580619
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse