Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You would expect an index seek to occur on the ‘AK_Employee_NationalIDNumber’ index; however, the execution plan clearly shows that an index scan is performed instead of an index seek.

To determine the cause of having an index scan, mouse over the index scan operation of the execution plan to display the tooltip containing additional details:

Under the ‘Predicate’ section of the tooltip see that the ‘CONVERT_IMPLICIT(int,[AdventureWorks].[HumanResources].[Employee].[NationalIDNumber],0)=(253022876)’ implicit conversion is being performed on the ‘NationalIDNumber’ column. This column value is being converted because the data type of the column mismatches the data type of the literal value being used in the compare. To resolve the data mismatch, change the data type of the literal value to match the data type of the column:

The new execution plan for the updated TSQL is the following:

Note that the index scan is replaced by an index seek operation, optimizing successfully the query. 

Use SQL Doctor to identify implicit conversions

Newtablink
aliasIDERA SQL Doctor
urlhttps://www.idera.com/productssolutions/sqlserver/sqldoctor
collects and analyzes your heaviest TSQL to help you identify implicit conversions along with other problems that impact query performance. The following is the resulting recommendation generated by
Newtablink
aliasIDERA SQL Doctor
urlhttps://www.idera.com/productssolutions/sqlserver/sqldoctor
for the example presented above (SDR-Q36 – Implicit conversion on a column may be causing index suppression):


You can click Show me the problem on the Recommendations window to display the TSQL.



Scroll pdf ignore
SQL Doctor get advice and recommendations on how to tune SQL performance.
Newtabfooter
aliasIDERA
urlhttp://www.idera.com
Newtabfooter
aliasProducts
urlhttps://www.idera.com/productssolutions/sqlserver
Newtabfooter
aliasPurchase
urlhttps://www.idera.com/buynow/onlinestore
|
Newtabfooter
aliasSupport
urlhttps://idera.secure.force.com/
|
Newtabfooter
aliasCommunity
urlhttp://community.idera.com
|
Newtabfooter
aliasResources
urlhttp://www.idera.com/resourcecentral
|
Newtabfooter
aliasAbout Us
urlhttp://www.idera.com/about/aboutus
|
Newtabfooter
aliasLegal
urlhttps://www.idera.com/legal/termsofuse

...