30.06.2013 Views

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SQL Server Execution Plans - Red Gate Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8: Advanced Topics<br />

Examining a parallel execution plan<br />

If you're performing these tests on a machine with a single processor, then you won't be<br />

able to see any parallel plans. Kalen Delaney supplied a method for simulating multiple<br />

processors in <strong>SQL</strong> <strong>Server</strong> Magazine, InstantDoc #95497 (available only to subscribers).<br />

In the <strong>SQL</strong> <strong>Server</strong> Configuration Manager, right-click the appropriate <strong>SQL</strong> <strong>Server</strong> service<br />

and edit the startup properties. Add a property "-Pn" which represents the number of<br />

processors that you want to simulate. You must then restart the service. This simulates<br />

parallel execution plans, but it does not actually give you parallel execution on a single<br />

processor machine.<br />

For more detail, read the article. However, I'll repeat the warning from the article: Never<br />

do this on a production system.<br />

We'll start with an aggregation query, of the sort that you might find in a data mart. If<br />

the dataset this query operates against is very large, it might benefit from parallelism.<br />

SELECT so.ProductID ,<br />

COUNT(*) AS Order_Count<br />

FROM Sales.SalesOrderDetail so<br />

WHERE so.ModifiedDate >= '2003/02/01'<br />

AND so.ModifiedDate < DATEADD(mm, 3, '2003/02/01')<br />

GROUP BY so.ProductID<br />

ORDER BY so.ProductID<br />

Listing 8.5<br />

Figure 8.4 shows the estimated execution plan, which seems straightforward.<br />

Figure 8.4<br />

299

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!