Created
July 24, 2015 14:08
-
-
Save Fhernd/1cc8285728d1876626be to your computer and use it in GitHub Desktop.
Rendimiento COALESCE y ISNULL en T-SQL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- OrtizOL - xCSw - http://ortizol.blogspot.com | |
DECLARE @i INT SET @i = 1 | |
DECLARE @CPU INT SET @CPU = @@CPU_BUSY | |
DECLARE @TiempoInicio DATETIME SET @TiempoInicio = GETDATE() | |
WHILE @i <= 1000000 | |
BEGIN | |
IF COALESCE('abc', 'def') = 'def' | |
PRINT 1 | |
SET @i = @i + 1 | |
END | |
PRINT 'COALESCE, sin argumentos NULL' | |
PRINT 'Tiempo total de CPU: ' + CONVERT(varchar, @@CPU_BUSY - @CPU) | |
PRINT 'Total en milisegundos: ' + CONVERT(varchar, DATEDIFF(ms, @TiempoInicio, GETDATE())) | |
PRINT '' | |
GO | |
DECLARE @i INT SET @i = 1 | |
DECLARE @CPU INT SET @CPU = @@CPU_BUSY | |
DECLARE @TiempoInicio DATETIME SET @TiempoInicio = GETDATE() | |
WHILE @i <= 1000000 | |
BEGIN | |
IF ISNULL('abc', 'def') = 'def' | |
PRINT 1 | |
SET @i = @i + 1 | |
END | |
PRINT 'ISNULL, sin argumentos NULL' | |
PRINT 'Tiempo total de CPU: ' + CONVERT(varchar, @@CPU_BUSY - @CPU) | |
PRINT 'Total en milisegundos: ' + CONVERT(varchar, DATEDIFF(ms, @TiempoInicio, GETDATE())) | |
PRINT '' | |
GO | |
DECLARE @i INT SET @i = 1 | |
DECLARE @CPU INT SET @CPU = @@CPU_BUSY | |
DECLARE @TiempoInicio DATETIME SET @TiempoInicio = GETDATE() | |
WHILE @i <= 1000000 | |
BEGIN | |
IF COALESCE(NULL, 'abc') = 'def' | |
PRINT 1 | |
SET @i = @i + 1 | |
END | |
PRINT 'COALESCE, primer argumento NULL' | |
PRINT 'Tiempo total de CPU: ' + CONVERT(varchar, @@CPU_BUSY - @CPU) | |
PRINT 'Total en milisegundos: ' + CONVERT(varchar, DATEDIFF(ms, @TiempoInicio, GETDATE())) | |
PRINT '' | |
GO | |
DECLARE @i INT SET @i = 1 | |
DECLARE @CPU INT SET @CPU = @@CPU_BUSY | |
DECLARE @TiempoInicio DATETIME SET @TiempoInicio = GETDATE() | |
WHILE @i <= 1000000 | |
BEGIN | |
IF COALESCE(NULL, 'abc') = 'def' | |
PRINT 1 | |
SET @i = @i + 1 | |
END | |
PRINT 'ISNULL, primer argumento NULL' | |
PRINT 'Tiempo total de CPU: ' + CONVERT(varchar, @@CPU_BUSY - @CPU) | |
PRINT 'Total en milisegundos: ' + CONVERT(varchar, DATEDIFF(ms, @TiempoInicio, GETDATE())) | |
PRINT '' | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment