|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 1:49 AM
Points: 10,990,
Visits: 10,540
|
|
Hugo Kornelis (4/1/2010) Wow! That is really intriguing.... Exactly my reaction when I first looked at your Connect item! I have added it to my watch list. Thanks, Hugo.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 2:27 AM
Points: 7,104,
Visits: 7,170
|
|
Paul White NZ (3/31/2010)
CirquedeSQLeil (3/31/2010)
Adam Machanic summarizes his testing here. In the comments, Adam notes that there seems to be no difference in SQL Server 2008... I think that's him expressing himself badly - the figues he gives for SQLS 2008 indicate that coalesce is now measurably faster than isnull.
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 2:27 AM
Points: 7,104,
Visits: 7,170
|
|
Paul White NZ (4/1/2010)
Hugo Kornelis (3/31/2010) ...I submitted a bug report... a case I constructed, based on this discussion, where COALESCE(..., 1) may erroneously return NULL (which should of course never happen).Voted, repro'd, and a sort-of 'workaround' added. The intersting reult here is that the MS reply recognises that the optimiser should recognise that the duplicated expression is just that, and evaluate it only once. So maybe it will get fixed sometime.
It would be good if that were to happen for case statements too, but given that the ANSI definition syas the simple version is a shorthand for the version duplicating the expression I guess it won't. The workaround in the reply works for case too, of course.
Tom Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 1:49 AM
Points: 10,990,
Visits: 10,540
|
|
Tom.Thomson (4/7/2010)
Paul White NZ (3/31/2010)
CirquedeSQLeil (3/31/2010)
Adam Machanic summarizes his testing here. In the comments, Adam notes that there seems to be no difference in SQL Server 2008... I think that's him expressing himself badly - the figues he gives for SQLS 2008 indicate that coalesce is now measurably faster than isnull. Did it? My memory was of mixed results. Can't actually be bothered to check again though
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 1:49 AM
Points: 10,990,
Visits: 10,540
|
|
Tom.Thomson (4/7/2010) The intersting reult here is that the MS reply recognises that the optimiser should recognise that the duplicated expression is just that, and evaluate it only once. So maybe it will get fixed sometime. I think it is important to say that this only applies to the specific expansion of COALESCE. I hope it does get fixed, but I don't expect for one moment that they will change the way COALESCE is implemented (with CASE). Will be an interesting one to watch.
It would be good if that were to happen for case statements too, but given that the ANSI definition syas the simple version is a shorthand for the version duplicating the expression I guess it won't. The workaround in the reply works for case too, of course. I agree - they won't change the ANSI-esque expansion.
Paul White SQL Server MVP SQLblog.com @SQL_Kiwi
|
|
|
|