update across tables comparing millions of records

  • I think you should look at removing all the OR statements. In general, an OR is bad for performance.

    Additionally, I would have a look at changing the IN statements in the inner queries to normal joins.

    
    
    ...
    WHERE XTELELINK IN
    (SELECT T.XTELELINK
    FROM TESTSQLVW T
    INNER JOIN
    DONTDIAL.dbo.DONTDIAL D
    ON T.Phone = D.Phone)
    OR ...

    Other things to speed it up is moving the DONTDIAL table inside the same database.

    And maybe, just maybe, make a view UNIONing all of the phonefields from XTELELINK together. This would facilitate removing the OR's a great deal. If you make it an indexed view, performance shouldn't be to bad.

  • Try this

    Update TELESCRP

    set xpriority = 99, xcallback = NULL

    from TELESCRP , TESTSQLVW , DONTDIAL.dbo.DontDial,

    where

    TELESCRP.XTELELINK = TESTSQLVW.XTELELINK

    and

    DONTDIAL.dbo.DontDial.Phone

    in ( phone, phone1, phone2, phone21, phone3 , phonenum )

    I suggest if you can check / post the plans for both statements. If there is a index on

    DONTDIAL.dbo.DontDial.Phone then it should use it.


    -- Amit



    "There is no 'patch' for stupidity."



    Download the Updated SQL Server 2005 Books Online.

  • small correction

    Update TELESCRP

    set xpriority = 99, xcallback = NULL

    from TELESCRP , TESTSQLVW , DONTDIAL.dbo.DontDial,

    where

    TELESCRP.XTELELINK = TESTSQLVW.XTELELINK

    and

    DONTDIAL.dbo.DontDial.Phone

    in ( TESTSQLVW.phone, TESTSQLVW.phone1, TESTSQLVW.phone2, TESTSQLVW.phone21, TESTSQLVW.phone3 , TESTSQLVW.phonenum )


    -- Amit



    "There is no 'patch' for stupidity."



    Download the Updated SQL Server 2005 Books Online.

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

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