I know a lot of such questions, but I can not find the one that concerns my question.
Looking at this question, Does IF EXIST (SELECT 1 FROM) change to IF EXIST (SELECT TOP 1 FROM) any side effects?
In particular, referring to this section in the answer:
select * from sys.objects
select top 1 * from sys.objects
select 1 where exists(select * from sys.objects)
select 1 where exists(select top 1 * from sys.objects)
I use some of my own tests to understand them correctly. As indicated in the answer:
select 1 where exists(select top 1 * from sys.objects)
select 1 where exists(select top 1 1 from sys.objects)
both invoke the same execution plan, and also invoke the same plan as
select 1 where exists(select * from sys.objects)
select 1 where exists(select 1 from sys.objects)
From my research on issues such as this one, “SELECT TOP 1 1” VS “IF EXISTS (SELECT 1” . I believe this is a consistent best practice:
select 1 where exists(select * from sys.objects)
My first question is: why is this preferable:
select 1 where exists(select 1 from sys.objects)
( "-1", ):
select top 1 * from sys.objects
select top 1 1 from sys.objects
, 80% ( 2), - 20%.
select 1 where exists(select 1 from sys.objects)
?