How to Increase Query Speed by 3 Orders of Magnitude with no Indexes

  • Stephen Hirsch

    SSCommitted

    Points: 1822

    Comments posted to this topic are about the item How to Increase Query Speed by 3 Orders of Magnitude with no Indexes

  • MikeAngelastro-571287

    SSCommitted

    Points: 1576

    Yes. Your boss did the right thing and it was brilliant. But couldn't the three hour query have been the result of an inadequate use-case?

  • Jeff Moden

    SSC Guru

    Points: 994238

    A short, sweet, and brilliant article! Bravo Stephen and spot on on all points especially on working with your "customers".

    There's only one problem with the scenario you're given... what if the "customers" had said the data had to be "up to date" as in "to the second" (or so)? That probably brings us to the real problem of not having enough time because of poorly estimated schedules or the corner office wants it real bad and, obviously, got it that way or no one really gave a damn when it came to design and coding. It's one of the reasons why I say to always plan and program as if there were at least million rows in each and every table.

    I don't know about others but I gave this article 5 stars for the message it carries about working with the customer. By the same token, I could have given this article MINUS 5 stars because (not having ANYTHING to do with the author) [font="Arial Black"]the boss actually isn't a hero [/font]because he is the one that should have managed things in such a fashion to PREVENT such problems from happening to begin with.

    Tell your boss I said "Welcome to the Lucky Rollers Club" and to start taking care of business because the answer could have been a whole lot different. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

    Helpful Links:
    How to post code problems
    Create a Tally Function (fnTally)

  • steve.vidal

    Valued Member

    Points: 52

    That's the most misleading title I've seen in a long time...

    I was personally interested in the story because I was confronted with a nearly identical situation (Laboratory System with screen taking up to 20 minutes to load). Now in my story, I did improve the query speed by 3 orders of magnitude, not just swipe the problem under the carpet... 😉

    How is this article going to help anyone actually trying to troubleshoot performance issues?:(

  • mark.schrier

    SSC Rookie

    Points: 44

    While it is a cute story, the real meat is in the advice at the end.

    1. Get to know your end users as people

    2. Learn their jobs and their concerns

    3. Don't undertake a design/analysis/programming project if you do not have free access to the end users and stake holders.

    4. End users will know significantly more about how they do their jobs and what works than they are given credit for.

    5. When an end user has a problem with the solution, always assume there is a problem until your have proof there is not. It is not the end users job to debug your code. Most shops assume there is no problem unless the user can prove it. This approach is fundamentally flawed.

    Using these guide lines, projects will run more smoothly and have a much better chance of finishing on target and on time.

  • Tim Monfries

    Valued Member

    Points: 55

    Solved in terms of perception only.

    Your boss fixed the problem of an overly odourous recycling plant by moving it someplace (or perhaps more correctly, sometime) else. The users aren't around to smell it anymore, but the garbage tip still stinks!

    I'd like to know what, if anything, was done to fix the underlying design/resource issues that produced the problem in the first place.

  • SQLRNNR

    SSC Guru

    Points: 281210

    Nice article. I think this is sometimes overlooked as a valid method to troubleshoot performance problems. The point is to provide a solution that meets the requirements without killing the system.

    Thanks very much for sharing.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • AspiringGeek-40457

    SSC Veteran

    Points: 235

    I'm definitely on the side of calling this an elegant solution. When you can define the frame, you can always win. It's not always this easy to do so, but when possible, ka-ching!

  • Paul Lancaster

    SSC Rookie

    Points: 45

    steve.vidal (7/13/2010)


    That's the most misleading title I've seen in a long time...

    I was personally interested in the story because I was confronted with a nearly identical situation (Laboratory System with screen taking up to 20 minutes to load). Now in my story, I did improve the query speed by 3 orders of magnitude, not just swipe the problem under the carpet... 😉

    How is this article going to help anyone actually trying to troubleshoot performance issues?:(

    Absolutely agreed! What the article describes is plain common sense; it's doesn't "increase query speed" at all, simply moves the load to a time when systems are under or less utilised. Been doing that for years.

  • gserdijn

    Hall of Fame

    Points: 3204

    As of midnight would be perfectly fine

    Good stories usually have a happy ending. Not exactly an eye-opener, but nevertheless a good reminder.

    We had it the other way round. Every night a job ran to populate a datawarehouse. The customer asked if it were possible to update the datawarehouse 4 times a day. It was - in this case - possible without any problems. Usually the business rules change for the worse.



    Dutch Anti-RBAR League

  • Jeff Moden

    SSC Guru

    Points: 994238

    gserdijn (7/14/2010)


    Dutch Anti-RBAR League

    I've just gotta love a signature line like that. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

    Helpful Links:
    How to post code problems
    Create a Tally Function (fnTally)

  • MVDBA

    SSC-Insane

    Points: 20353

    if the initial query took 3 hours to populate 1 screen then i imagine the database developers need shooting.

    i just can't conceive that there were not other solutions that did not require a snapshot.

    MVDBA

  • Chris Howarth-536003

    SSCommitted

    Points: 1775

    I'm in total agreement that in this scenario, and for new functionality in particular, the requirements should first be questioned before spending too much time/money on tuning. Ideally the project would not have got this far as the requirements such as this should be agreed as early on as possible in the project.

    I encountered a similar scenario a few years ago and (as a dev/operational DBA) I questioned whether or not the users actually needed all of the data that was being displayed on-screen. The answer from the Business was 'no' - it transpired that the 'requirement' for the superfluous data was added to the solutions documentation by one of the project's Business Analysts who had gotten a little carried away.

    After modifying the query appropriately the execution time went down from about 5 mins to less than 1s, which is a big difference when waiting for a form to populate whilst a customer is on the other end of the phone.

    Chris

  • Dan Moran-347932

    SSC Rookie

    Points: 27

    Yes, flattened structures are faster than complex structures. Next?

  • Phil Factor

    SSCoach

    Points: 19823

    We all admire bosses who, to use a British phrase, 'wear their underpants outside their trousers'. (play superman in a crisis). I support this type of solution, but because it is necessary rather than sufficient. As a database developer, I simply hate the thought that that query is still there, grinding away for three hours, albeit only once a day. This is a time-bomb. When the usage of the system quadruples, what then? No! I'm a firm believer in the idea that there are very few queries that can't be improved, and, usually, anything that takes more than ten seconds ought to be improved. In the SQL Speed Phreak challenge on Ask.SQLServerCentral.com we regularly increase performance by two orders of magnitude. The last winner was an SSIS task!

    Best wishes,
    Phil Factor
    Simple Talk

Viewing 15 posts - 1 through 15 (of 88 total)

You must be logged in to reply to this topic. Login to reply