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.

Chapter 2: Graphical <strong>Execution</strong> <strong>Plans</strong> for Basic Queries<br />

Assuming that the number of rows in a table is relatively small, Table Scans are generally<br />

not a problem. On the other hand, if the table is large and many rows are returned, then<br />

you might want to investigate ways to rewrite the query to return fewer rows, or add an<br />

appropriate index to speed performance.<br />

RID Lookup<br />

RID Lookup is the heap equivalent of the Key Lookup operation. As was mentioned<br />

before, non-clustered indexes don't always have all the data needed to satisfy a query.<br />

When they do not, an additional operation is required to get that data. When there is a<br />

clustered index on the table, it uses a Key Lookup operator as described above. When<br />

there is no clustered index, the table is a heap and must look up data using an internal<br />

identifier known as the Row ID or RID.<br />

If we specifically filter the results of our previous DatabaseLog query using the<br />

primary key column, we see a different plan that uses a combination of an Index Seek<br />

and a RID Lookup.<br />

SELECT *<br />

FROM [dbo].[DatabaseLog]<br />

WHERE DatabaseLogID = 1<br />

Listing 2.6<br />

80

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

Saved successfully!

Ooh no, something went wrong!