Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Data Management

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Five things wouldn’t miss in SQL ServerSQL Meme: Tagged: 5 things SQL Server should drop »
    comments

    Using Database Engine Tuning Advisor can lend a great deal to a DBA. All you need to do is plug in a query, hit start and viola, instant 99% performance increase estimates. OK, it might not be all that but it can give you some pretty good suggestions for increasing performance. Is this too good to be true? In some cases, yes, it is.

    Let’s look at something I just ran across. I do actively use DTA. It’s a great tool and it makes tuning extremely large queries quick with reviewing suggests along with execution plans to ensure recommendations are sound. Even better and my primary reason for using DTA is it writes the CREATE statements for you. Remember, a lazy DBA is actually a more efficient DBA.

    This morning however, DTA was being less than helpful.

    A query went by my monitoring tools that sent my disk queue length threw the roof. Well, it went to 8 but as most DBAs know, 3 will make us squirm in our chairs. Once I reviewed the query, it wasn’t really all that bad. In fact, I think it was well written by the vendor. Checking the execution plan I could see there was just some covering index needs to ensure parallelism and some key lookup steps were removed. So I opened DTA already knowing pretty much what I wanted to do and ran the query through it. The results were about what I expected but looking closer I saw this

    1. CREATE NONCLUSTERED INDEX [_dta_index_9_379148396__K1] ON [dbo].[WHDR]
    2. (
    3.     [WO_ID] ASC
    4. )WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF) ON [PRIMARY]

    Why is that a problem you might ask? Well, it might not be a problem if you are working on a HEAP table and that typical work order ID is really in need of a nonclustered index. At that point we would want the awesomeness of a clustered index anyhow.


    Here is the biggest problem. There is a clustered index on the table and that clustered index only consists of the WO_ID. Yes, that would be an extremely big problem as far as performance goes. You would have two indexes doing the same thing and on every change to the table, you would be updating them at the same time. In a large table that cost can show quick and become painful to the users.




    So my tip for the day; don’t forget DTA as a beneficial tool to be the lazy DBA we all speak of. It can truly help you even if that is simply taking some code writing shortcuts. But, believe it as much as you believe the first Google hit you get back when researching a problem. As Janice Lee (Twitter | Blog) says in Save Me, Google, “Google told him to. He was in trouble, he panicked, and he trusted his salvation to Google.” Well, don’t fall into the points that Janice put together so well in that blog. Even the tools that are meant to assist us in doing our jobs better can be wrong. They are suggestions that require as much review as anything else going into your database servers.

    About the Author

    Ted Krueger is a SQL Server MVP and has been working in development and database administration for 13+ years. Specialties range from High Availability and Disaster / Recovery setup and testing methods down to custom assembly development for SQL Server Reporting Services. Ted blogs and is also one of the founders of LessThanDot.com technology community. Some of the articles focused on are Backup / Recovery, Security, SSIS and working on SQL Server and using all of the SQL Server features available to create stable and scalable database services. @onpnt
    Social SitingsTwitterLinkedInLTD RSS Feed
    2883 views
    Instapaper

    6 comments

    Comment from: SQLDenis [Member] Email
    SQLDenis You know what...I have never use DTA and I believe I have used the Index Tuning Wizard in SQL Server 2000 only once or twice. Maybe it is because I am a developer and I know when looking at a query what I should have in terms of indexes.

    The Dynamic Management Views are also a great help to discover unused indexes...because you know sometimes people get 'creative' and 'excited' when adding indexes, they see the performance improvement when adding an index on a column and then think if one index is good then many must be better. So before you know if you have more indexes than columns :-)
    05/11/10 @ 10:03
    Comment from: niikola [Member] Email
    niikola There are queries that could benefit from additional index, same as clustered one.

    Simplest one would be Select WO_ID from WHDR or Select WO_ID from WHDR where WO_ID between @p1 and @p2

    In most cases you don't need something like that, except if you have really a lot of those queries and your row size is much bigger than WO_ID size.
    05/13/10 @ 11:19
    Comment from: Paul White NZ [Visitor]
    Paul White NZ Hey Ted,

    I agree with niikola. The DTA appears to be correctly considering the density of the index when making its recommendation (the clustered index is the least dense index possible).

    See this link for an example, and an analysis of the performance implications.

    Paul
    05/15/10 @ 04:39
    Comment from: Kevin Boles [Visitor] Email
    Kevin Boles As an independent consultant I have made a LOT of money over the past 5 years cleaning up the messes that clients have created for themselves by using the DTA to perform their indexing strategy. It is truly HORRID in sooo many ways. I do appreciate the fact that it is out there and provides me with lots of work though!
    05/15/10 @ 07:30
    Comment from: Ted Krueger (onpnt) [Member]
    Ted Krueger (onpnt) Thanks for the comments everyone. Good stuff!
    05/15/10 @ 19:59
    Comment from: yoelhalb [Visitor]
    yoelhalb There are many and many benefits of having an index on WO_ID column, something that you can check yourself by creating the index and comparing the IO and time statistics as well as the CPU and IO cost.
    Farther more SQL Server will most of the time use a nonclustered index not just if the WO_ID column s the first or any column in the index but also if it is the second column! sometimes even when there is a nonclustered index with WO_ID as its primary column.
    This also has major implications, consider a query "SELECP TOP 1 WO_ID FROM WHDR" while one might expect that it will return the actual first entry, it is not the case because it might turn out to use an index which WO_ID is the secondary column (based on the internal cost staistics), and to get correct results one must add "ORDER BY WO_ID" or use an index hint to force the desired index.
    11/24/11 @ 11:17

    Leave a comment


    Your email address will not be revealed on this site.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)