change query

  • Hello,

    Any way to rewrite this query to better perform?

    Select SD.ORDER_ID,,MD.Origin, TR.Origin

    fromAOrders SD,

    DATACollect MD,

    DATACollect TR,

    DataTrace BC,

    DataTrace ED

    where SD.ORDER_ID = MD.ORDER_ID

    and MD.DESC_ID = BC.DESC_ID

    and SD.ORDER_ID = TR.ORDER_ID

    and TR.DESC_ID = ED.DESC_ID

    Thanks.

  • Please see the link below on how to post performance issues



    Clear Sky SQL
    My Blog[/url]

  • First, I'd strongly suggest switching to ANSI 92 syntax

    SELECT...

    FROM a

    JOIN B

    ON a.id = b.id

    Second, you don't have any kind of filtering, so the query is going scan all the data on all the tables and there's no way to make that faster except by buying more memory or faster disks.

    Finally, follow the link provided and send information like the structure, sample data and, most importantly, execution plans. There's no way for us to see what's happening on your machine without this information.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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