Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Queries, execution plans and "Parallelism"

So I'm (still) going through some slow legacy sql views used to do calculate some averages and standarddeviations on a (sometimes) large set of data. What I end up with are views joining views joining views etc.

So I though I would review the execution plan for my query. And it immediately suggested a missing index, which I then implemented. But it's still unbearably slow (so slow it times out the VB6 app querying it for data ;) )

So upon studying the execution plan further, I see that what costs the most (about 8% each in my case) are "Paralellism" cases. Mostly "Distribute Streams" and "Repartition Streams". What are these?

like image 681
Christian Wattengård Avatar asked Oct 05 '10 08:10

Christian Wattengård


1 Answers

Distribute Streams and Repartion Streams are operations that occur when the SQL optimizer chooses to use Parallel Query Processing. If you suspect that this is causing an issue with your query, you can force SQL Server to only use one CPU with the MAXDOP query hint, as illustrated below.

select *
    from sys.tables
    option (maxdop 1)
like image 146
Joe Stefanelli Avatar answered Oct 03 '22 04:10

Joe Stefanelli