sql server optimize statement

  • I have a question on how to optimize t-sql statement in a sql server 2008 r2 database. In my company one database is being redesigned into 9 other tables. This is due to to the one main table having everyrthing in it the entire database needed.

    I have a stored procedure that i need to change. This stored procedure in the old database only needed to refer to the one table. Now I need to join 9 tables together to obtain the same information.

    **Note this stored procedure is used to supply information into a C#.net 2008 windows application. The application displays information from this stored procedure for users to see. Basically i need all this inforamtion for the new version of the application to work.

    Part of the problem is some of the new tables do not contain any inforamtion, since the original may not have contained any information. This, i need to do left outer joins so all rows display.

    The new database has one table called 'NEW' that has lots of columns the are separate keys to the new tables.

    Thus, can you tell me what to do to optimize this query?

  • In your case it's very simple:

    You just need to apply query optimisation techniques and your query will fly.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • wendy the devil is in the details;

    we'd proably need to see the actual execution plan of the "new" query hitting those 9 tables to offer concrete advice;

    that actual execution plan may show, for example, adding an index that includes a couple of columns will greatly enhance the perforamnce...but without the details , we can't help with anything other than generic advice.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • If you are looking for optimization techniques and steps, you can visit the site in my signature. Something you might want to try with those empty tables is to load them with dummy data (few hundred thousand rows) and make sure your queries still run fine. That way you won't have to worry about things running slow in the future as they fill up.

    Jason

    Webmaster at SQL Optimizations School

Viewing 4 posts - 1 through 3 (of 3 total)

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