{"id":727,"date":"2004-06-12T22:18:37","date_gmt":"2004-06-12T22:18:37","guid":{"rendered":"\/blogs\/kimberly\/post\/MSDN-Webcast-SQL-Index-Tuning-QA-Tools.aspx"},"modified":"2013-01-11T23:14:06","modified_gmt":"2013-01-12T07:14:06","slug":"msdn-webcast-sql-index-tuning-qa-tools","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/msdn-webcast-sql-index-tuning-qa-tools\/","title":{"rendered":"MSDN Webcast SQL Index Tuning Q&#038;A: Tools"},"content":{"rendered":"<p><FONT size=3><br \/>\n<P><STRONG><FONT size=4>Tools Questions:<\/FONT><\/STRONG><\/P><br \/>\n<P><\/FONT><B style=\"mso-bidi-font-weight: normal\"><FONT color=#000000><FONT face=Arial><FONT size=3>Q: Isn&#8217;t there some issue with profiler where it does not recognize DBName but only the DBID?<?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" \/><o:p><\/o:p><\/FONT><\/FONT><\/FONT><\/B><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><FONT face=Arial color=#000000 size=3>Well, this is a good one &#8211; and a frustrating one as well. It is true that Profiler doesn&#8217;t always generate a data column value for every type of event. So &#8211; if you setup filters you will only filter rows which have a value for that data column. If you ONLY want to see things with a very specific value it can take quite a bit of time to remove all of the uninteresting events to narrow it down to only what you need. In the SQL Server Books Online there is a topic for each category &#8211; for example: <B style=\"mso-bidi-font-weight: normal\">Stored Procedures Event Category<\/B> has a listing of all of the data columns that are produced for each event. This is a bit tedious to go through though and there&#8217;s a nice full html version that&#8217;s available on Gert Draper&#8217;s website: <\/FONT><A href=\"http:\/\/www.sqldev.net\/\"><FONT face=Arial size=3>www.SQLDev.net<\/FONT><\/A><FONT face=Arial color=#000000 size=3>. Checkout this link specifically: <\/FONT><A href=\"http:\/\/sqldev.net\/misc\/SQLTraceEventMatrix.htm\"><FONT face=Arial size=3>http:\/\/sqldev.net\/misc\/SQLTraceEventMatrix.htm<\/FONT><\/A><FONT face=Arial color=#000000 size=3> <\/FONT><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><o:p><FONT face=Arial color=#000000 size=3>&nbsp;<\/FONT><\/o:p><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><B style=\"mso-bidi-font-weight: normal\"><FONT face=Arial><FONT color=#000000><FONT size=3>Q: Is it true that ITW is beneficial because it can predict how the optimizer will benefit most from the indexes it recommends? Sometimes I find that the ITW recommends statistics that hinder the query performance. Do you feel comfortable using it for the most part?<o:p><\/o:p><\/FONT><\/FONT><\/FONT><\/B><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><FONT face=Arial color=#000000 size=3>Ok, so there are really two questions here &#8211; first &#8220;how does ITW work?&#8221; and second &#8220;is it always a good thing?&#8221; <\/FONT><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><o:p><FONT face=Arial color=#000000 size=3>&nbsp;<\/FONT><\/o:p><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><FONT face=Arial color=#000000 size=3>As for how it works &#8211; yes, you&#8217;re correct&#8230; ITW hypothesizes about indexes by creating statistics about your data, looking at the queries in the workload and then based on how the optimizer would optimize &#8211; it tells you which indexes would be best serve your data!<\/FONT><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><o:p><FONT face=Arial color=#000000 size=3>&nbsp;<\/FONT><\/o:p><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><FONT color=#000000><FONT size=3><FONT face=Arial>As for whether or not it&#8217;s always a good thing&#8230; the first thing I&#8217;ll jokingly say is &#8211; <I style=\"mso-bidi-font-style: normal\">Is there ever an ALWAYS good, good thing?<\/I> <\/FONT><SPAN style=\"FONT-FAMILY: Wingdings; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-char-type: symbol; mso-symbol-font-family: Wingdings\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Wingdings\">J<\/SPAN><\/SPAN><FONT face=Arial> Joking aside, there is some truth to this (although rare). I do feel comfortable using ITW and because the statistics are based on real data, not updated if they&#8217;re not used (there&#8217;s a good whitepaper that explains statistics <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/dnsql2k\/html\/statquery.asp?frame=true\">here<\/a><\/FONT><\/FONT><\/FONT><FONT face=Arial color=#000000 size=3>), so in general, statistics don&#8217;t usually hinder query (or server) performance. However, having an extremely large number of statistics and indexes can increase optimization time (in analyzing all of these choices) and this may in fact be something you&#8217;re seeing. <\/FONT><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><o:p><FONT face=Arial color=#000000 size=3>&nbsp;<\/FONT><\/o:p><\/P><br \/>\n<P class=MsoNormal style=\"MARGIN: 0in 0in 0pt\"><B style=\"mso-bidi-font-weight: normal\"><FONT size=3><FONT face=Arial><FONT color=#000000>Q: When statistics exists on some of my client tables, SQL Server sometimes chooses to use an index that is less beneficial (even after we update stats with full scan). In some cases, we&#8217;ve had to force the index using optimizer hints. As a result, we disable &#8220;AUTO CREATE&#8221; and only create indexes when performance issues arise and are needed. Granted this isn&#8217;t the best method but until the tables become really large we find that some queries work fine.<o:p><\/o:p><\/FONT><\/FONT><\/FONT><\/B><\/P><br \/>\n<P><FONT color=#000000><SPAN style=\"FONT-SIZE: 12pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA\">Ok, well there&#8217;s a lot to this one. First, I&#8217;d say that there&#8217;s a difference between just having statistics and having the right indexes. There are some cases where ONLY having statistics isn&#8217;t good enough to give SQL Server enough information to proceed and instead they make incorrect decisions. It&#8217;s generally when SQL Server only has statistics for individual columns and doesn&#8217;t have better information for a combination of columns (<I style=\"mso-bidi-font-style: normal\">wow, this is hard to describe in a short Q&amp;A<\/I>). But &#8211; I&#8217;ll sum it up to say that statistics aren&#8217;t always perfect &#8211; some assumptions may need to be made and sometimes those assumptions don&#8217;t work out because the data isn&#8217;t evenly distributed&#8230; So, if the indexes that exist are not &#8220;perfect&#8221; for the query SQL Server ends up not doing as good of a job as it might if it had the right indexes&#8230; If it helps, I have a class where I get into more details on statistics (a whole module on just statistics <\/SPAN><SPAN style=\"FONT-SIZE: 12pt; FONT-FAMILY: Wingdings; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; mso-char-type: symbol; mso-symbol-font-family: Wingdings; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA\"><SPAN style=\"mso-char-type: symbol; mso-symbol-font-family: Wingdings\">J<\/SPAN><\/SPAN><SPAN style=\"FONT-SIZE: 12pt; FONT-FAMILY: Arial; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA\">) that explains a lot more details&#8230; It&#8217;s hard to sum up in a sentence or two BUT I would guess that a bit more tuning (i.e. more real indexes and not just statistics) <B style=\"mso-bidi-font-weight: normal\">might<\/B> help solve the problem&#8230; Really, hard to say in a quick chat but that really shouldn&#8217;t be the majority of the time.<\/SPAN><\/FONT><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tools Questions: Q: Isn&#8217;t there some issue with profiler where it does not recognize DBName but only the DBID? Well, this is a good one &#8211; and a frustrating one as well. It is true that Profiler doesn&#8217;t always generate a data column value for every type of event. So &#8211; if you setup filters [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,36,58,78],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-events","category-indexes","category-resources","category-tips"],"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/kimberly\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}