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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Introduction<br />

Every day, out in the various discussion boards devoted to Microsoft <strong>SQL</strong> <strong>Server</strong>, the<br />

same types of questions come up repeatedly:<br />

• Why is this query running slow?<br />

• Is <strong>SQL</strong> <strong>Server</strong> using my index?<br />

• Why isn't <strong>SQL</strong> <strong>Server</strong> using my index?<br />

• Why does this query run faster than this query?<br />

• And so on (and on).<br />

The correct response is probably different in each case, but in order to arrive at the<br />

answer you have to ask the same return question every time: have you looked at the<br />

execution plan?<br />

<strong>Execution</strong> plans show you what's going on behind the scenes in <strong>SQL</strong> <strong>Server</strong>. They can<br />

provide you with a wealth of information on how <strong>SQL</strong> <strong>Server</strong> is executing your queries,<br />

including the points below.<br />

• Which indexes are getting used, and where no indexes are being used at all.<br />

• How the data is being retrieved, and joined, from the tables defined in your query.<br />

• How aggregations in GROUP BY queries are put together.<br />

• The anticipated load, and the estimated cost, that all these operations place upon<br />

the system.<br />

All this information makes the execution plan a fairly important tool in the tool belt of<br />

database administrator, database developers, report writers, developers, and pretty much<br />

anyone who writes T-<strong>SQL</strong> to access data in a <strong>SQL</strong> <strong>Server</strong> database.<br />

13

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

Saved successfully!

Ooh no, something went wrong!