update across tables comparing millions of records

  • You could try replacing the WHERE IN with WHERE EXISTS (look it up in BOL) as I read the EXISTS is generally much faster than IN as it uses a binary comparison as opposed to a potential repeated lookup - also try putting a trace on the databases and then use the Index Tuning Wizard to see if your columns are indexed optimally ...

    Steve

  • Is it the SELECT part of the statement that is taking a long time to run (i.e. the where((XTELELINK IN.....), or is it the actual UPDATEs (i.e. are there so may updates that they will take ages, regardless of the SELECT part)?

    Either way, you may find it runs quicker if you do the updates in smaller chunks i.e. one update for each one of the 'OR XTELELINK IN ...'

    Also, SQL Server will treat an IN statement as a series of OR statements. OR statements often stop the query optimiser from using an index. You may be better off using 'UPDATE XTELELINK FROM XTELELINK INNER JOIN DONTDIAL....', which may prompt SQL Server to you the index you had expected.

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

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