{"id":9,"date":"2011-05-16T16:22:39","date_gmt":"2011-05-16T10:52:39","guid":{"rendered":"http:\/\/pramodsingla.wordpress.com\/?p=9"},"modified":"2011-05-16T16:22:39","modified_gmt":"2011-05-16T10:52:39","slug":"cause-of-index-scan","status":"publish","type":"post","link":"https:\/\/pramodsingla.com\/?p=9","title":{"rendered":"SQL Server &#8211; Cause Of Index Scan"},"content":{"rendered":"<p style=\"text-align:justify;\"><strong><span style=\"color:#000000;\">Question: Why Index Scan is happening even thought index exists on predicate column?<\/span><\/strong><\/p>\n<p><strong><span style=\"color:green;\">Ans:<\/span><\/strong><br \/>\nGenerally,Query Optimizer (QO) tries to use an Index Seek which means that optimiser has found a useful index to retrieve recordset. But sometimes despite of an index being created on a query predicate columns, Query Optimiser uses<em>\u00a0Index Scan<\/em> instead of <em>Index Seek<\/em>. The causes of using index scan are explained below.<\/p>\n<p>Causes of Index Scan<\/p>\n<ul>\n<li>The index is not selective enough.Use DBCC show_statistics (&#8216;tableName,&#8217;indexName&#8217;) to check the selectivity of an index. Selectivity is inversely proportional to the density. It means low density of the index is good.<\/li>\n<li>The number of pages returned by the query have reached the <a href=\"http:\/\/www.sqlskills.com\/blogs\/kimberly\/the-tipping-point-query-answers\/\">tipping point<\/a>.<\/li>\n<li>The first column of the index is not included in the query predicate.<\/li>\n<li>Statistics are stale.<\/li>\n<li>Functions like upper, lower, substring are applied on the predicate columns of the query.<\/li>\n<li>In like operator, % wild character is used as the first character in the search string, e.g.<br \/>\nselect *from Person. where City like &#8216;%Both&#8217;<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: Why Index Scan is happening even thought index exists on predicate column? Ans: Generally,Query Optimizer (QO) tries to use[&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[23,29],"tags":[61,100,144],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pramodsingla.com\/index.php?rest_route=\/wp\/v2\/posts\/9"}],"collection":[{"href":"https:\/\/pramodsingla.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pramodsingla.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pramodsingla.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pramodsingla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9"}],"version-history":[{"count":0,"href":"https:\/\/pramodsingla.com\/index.php?rest_route=\/wp\/v2\/posts\/9\/revisions"}],"wp:attachment":[{"href":"https:\/\/pramodsingla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pramodsingla.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pramodsingla.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}