Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2006
    Posts
    55

    Unanswered: optimizing stored procedures

    hi all,
    i'm working in a database, i'm not the creater of it, and was assigned to optimize the stored procedures running against this database.
    can someone tell me what steps should i follow to check these SP's and to what should i look at and what can be done to optimise them.

    thanks experts
    Peace out
    Mr joka

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    It might be a two line question but it is a massive subject. People make their careers out of this.

    read stuf here:
    http://www.sql-server-performance.com/
    Learn to read execution plans.
    Learn about SET STATISTICS IO
    Learn to use profiler.
    Read BoL (section on Optimising Database Performance).
    Learn your database.
    Learn about indexing strategies.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    First make sure all the critical joins are indexed. Then eliminate any cursors or loops.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    I usually I just ask the QA people what parts of the app sucks the will to live out of them and then I trace those screens to identify the really big pieces of suck ass code and I look at the execution plans of those queries. I like being reactive.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    exactly. the ONLY sure way to find where the perf problems are is to measure.

    ask any dev where the most time is spent in their code, and 90% will give you the wrong answer. the other 10% are right only because they have profiled it.

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I would trac it all to a table, th query the damn thing for the longest running pieces of code...

    I guess we could make you look like a hero, sinve it seems no one else knows what's going on.

    How big is this company?

    And how what's your experience level

    And do you have SQL Server client tools installed

    Do you know what books online is?

    Do you know what Google is?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Brett Kaiser
    I guess we could make you look like a hero
    ....
    Quote Originally Posted by Brett Kaiser
    Do you know what Google is?
    Downgrading as you type.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  8. #8
    Join Date
    May 2004
    Location
    Seattle
    Posts
    1,313
    There are some good articles about perf tuning here:

    http://www.sql-server-performance.co...erformance.asp
    http://www.sql-server-performance.co...cles_audit.asp

    in particular this one will show you how to use profiler for catching the biggest pigs in your database:
    http://www.sql-server-performance.co...ce_audit10.asp

    and elsewhere on that site.

    Be aware, however, sql is not the only process that can kill your perf. compiled code can be poorly written too. for compiled code you need to use a different profiling tool (I usually use perf studio in VS).

  9. #9
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    I trace all the queries to a table, as Brett mentioned. Then query it for the total number of reads grouped by say the first 50 or 100 characters of the textdata field. I find it is usually better to tune the average running query that runs 1,000's of times per day than the one pig that runs once at midnight. With all the variations that the textdata field can have, getting that aggregate right is a challenge, though.

  10. #10
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Quote Originally Posted by pootle flump
    ....
    Downgrading as you type.
    Are you saying that you should assume something about someone's experience?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  11. #11
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Nope - but if you take a poster on a forum from not knowing what google is to being a hero dba then I will eat all my hats.

    Anyway yes - the OP needs to identify the sprocs to tune and then needs to learn the skills to tune them. Or post them here of course.
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •