Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2008
»
SQL Server 2008 - General
»
“SELECT 1″ rather than a “SELECT *” when...
15 posts, Page 2 of 2
««
1
2
“SELECT 1″ rather than a “SELECT *” when using an EXISTS or a NOT EXISTS clause”.
Rate Topic
Display Mode
Topic Options
Author
Message
amenjonathan
amenjonathan
Posted Friday, February 11, 2011 1:48 PM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, September 20, 2012 5:21 PM
Points: 84,
Visits: 391
I also use SELECT NULL.
Personally if something is faster and there's virtually no complexity difference, I use the faster version. Why waste where there is no need is my motto.
My SQL Server Blog
Post #1062821
luckysql.kinda
luckysql.kinda
Posted Friday, February 11, 2011 4:31 PM
Old Hand
Group: General Forum Members
Last Login: Wednesday, April 24, 2013 11:19 AM
Points: 309,
Visits: 645
Cost Analysis Among EXISTS (SELECT 1), EXISTS (SELECT COUNT(1)), EXISTS (SELECT *) AND EXISTS (SELECT TOP 1)
should help
-lucky
Post #1062892
GilaMonster
GilaMonster
Posted Saturday, February 12, 2011 1:17 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 1:57 PM
Points: 37,687,
Visits: 29,945
luckysql.kinda (2/11/2011)
Cost Analysis Among EXISTS (SELECT 1), EXISTS (SELECT COUNT(1)), EXISTS (SELECT *) AND EXISTS (SELECT TOP 1)
should help
Not really. Firstly there's no cost analysis there, no testing, no numbers, nothing other than the blogger's untested opinion, and one of the queries he lists is logically different from the others.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1062946
GilaMonster
GilaMonster
Posted Saturday, February 12, 2011 1:20 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 1:57 PM
Points: 37,687,
Visits: 29,945
amenjonathan (2/11/2011)
I also use SELECT NULL.
Personally if something is faster and there's virtually no complexity difference, I use the faster version. Why waste where there is no need is my motto.
The point is, it's not significantly faster, it's a couple of nanoseconds at best. It's micro-optimisation, it's a waste of time for no value.
Use EXISTS (Select *, EXISTS (Select 1, EXISTS (Select NULL, or any other form as they are not going to make anything resembling a noticeable difference.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1062947
amenjonathan
amenjonathan
Posted Monday, February 14, 2011 9:25 AM
SSC Journeyman
Group: General Forum Members
Last Login: Thursday, September 20, 2012 5:21 PM
Points: 84,
Visits: 391
GilaMonster (2/12/2011)
amenjonathan (2/11/2011)
I also use SELECT NULL.
Personally if something is faster and there's virtually no complexity difference, I use the faster version. Why waste where there is no need is my motto.
The point is, it's not significantly faster, it's a couple of nanoseconds at best. It's micro-optimisation, it's a waste of time for no value.
Use EXISTS (Select *, EXISTS (Select 1, EXISTS (Select NULL, or any other form as they are not going to make anything resembling a noticeable difference.
If I'm typing it out for the first time and I type SELECT NULL instead of SELECT *, I don't see how that wastes any time. Yes it does not provide a lot of value, but hey a tiny amount of value for free is still better than no value for free. Also, again this is just the way I do things, it helps me stay vigilant with optimization.
Again my motto is why not do what's most optimal if it doesn't require any additional work?
My SQL Server Blog
Post #1063623
« Prev Topic
|
Next Topic »
15 posts, Page 2 of 2
««
1
2
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.