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.

Figure 5.7<br />

Chapter 5: Controlling <strong>Execution</strong> <strong>Plans</strong> with Hints<br />

As you can see, the query uses a mix of Nested Loops and Hash Match operators to put<br />

the data together, and it runs in around 214ms. Now, let's view the I/O output of the<br />

query. This can be done by navigating from the main menu, Query | Query Options,<br />

selecting the Advanced tab and selecting the Set Statistics I/O check box.<br />

Table 'Illustration'. Scan count 1, logical reads 273…<br />

Table 'ProductModelIllustration'. Scan count 1, logical reads 183…<br />

Table 'Worktable'. Scan count 0, logical reads 0…<br />

Table 'ProductModel'. Scan count 1, logical reads 14…<br />

Table 'Product'. Scan count 1, logical reads 15…<br />

Listing 5.8<br />

Most of the reads come from the Illustration and ProductModelIllustration<br />

tables. It occurs to you that allowing the query to perform all those Hash Match join<br />

operations may be slowing it down because of the reads and writes in tempdb, so you<br />

decide to change the behavior by adding the LOOP JOIN hint to the end of the query.<br />

OPTION ( LOOP JOIN );<br />

Listing 5.9<br />

186

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

Saved successfully!

Ooh no, something went wrong!