Created
March 16, 2021 18:31
-
-
Save FilipDeVos/3f9f0ab9396e2761b7420e7573d584c2 to your computer and use it in GitHub Desktop.
Compare Select 1 vs Select * in SQL Server
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
Table 'test'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. | |
if exists(select 1 from test) | |
|--Compute Scalar(DEFINE:([Expr1004]=CASE WHEN [Expr1005] THEN (1) ELSE (0) END)) | |
|--Nested Loops(Left Semi Join, DEFINE:([Expr1005] = [PROBE VALUE])) | |
|--Constant Scan | |
|--Clustered Index Scan(OBJECT:([master].[dbo].[test].[ck_test1])) | |
Table 'test'. Scan count 1, logical reads 2, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0. | |
if exists(select 1 from test) | |
|--Compute Scalar(DEFINE:([Expr1004]=CASE WHEN [Expr1005] THEN (1) ELSE (0) END)) | |
|--Nested Loops(Left Semi Join, DEFINE:([Expr1005] = [PROBE VALUE])) | |
|--Constant Scan | |
|--Clustered Index Scan(OBJECT:([master].[dbo].[test].[ck_test1])) |
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
select id into test from sysobjects | |
create clustered index ck_test1 on test(id) | |
set statistics io on | |
set statistics profile on | |
if exists(select * from test) | |
begin | |
print 'yes' | |
end | |
if exists(select 1 from test) | |
begin | |
print 'yes' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment