Home Forums SQL Server 2008 T-SQL (SS2K8) Function in Joining column degrades performance in 2008 RE: Function in Joining column degrades performance in 2008

  • aravind-305595 (7/9/2010)


    Hi, Thanks all. I thought to re-write that piece of code with suggestion given in this forum. Now I face another issue with the joins, my code looks like,

    update table1 set col1 = s.col1

    from table1 w inner join [SQLServer2].[database1].[dbo].[table1] s on w.col2 + ':' + w.col3 = s.col2 and w.col4 = s.col3

    where w.col1 is null

    and w.col2 is not null.

    I am using two concatenated columns the join and the joining table is from a linked server. The table1 has around 2 million records.

    The same query works in 2 minutes in SQL 2000 but it takes around 18 minutes in SQL 2008.

    I dont know why the joins degrade the performance for these kind of queries in SQL 2008. Please suggest some best idea to overcome this issue. Again if I have to re-write his code, I am not sure how many more will come with this kind of scenario in the joins.

    The concatenation of two columns is going to kill performance. You won't be able to use indexes. Better to have a calculated column that you can index for this.

    Also, are you hopping servers? If so, you're going to get smacked with the fact that it has to bring all the data back from the second server for processing on the first one. As written it won't filter the data on the second server. Instead you would need to use OPENQUERY and pass parameters to filter the data on the second server before it retrieves it.

    "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