Re: just a silly thing maybe...
From: Steve Kass (skass_at_drew.edu)
Date: 11/11/04
- Next message: Tudor Sofron: "Dynamic sql"
- Previous message: Scott Ivey: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- In reply to: Roji. P. Thomas: "Re: just a silly thing maybe..."
- Next in thread: Uri Dimant: "Re: just a silly thing maybe..."
- Reply: Uri Dimant: "Re: just a silly thing maybe..."
- Reply: Itzik Ben-Gan: "Re: just a silly thing maybe..."
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Nov 2004 09:41:54 -0500
Roji,
What do you mean by "better results"? I don't see anything at the
link you posted to suggest that. It's very unlikely that
count(T.columnName) will be faster than count(*). They should be
evaluated in the same way if T.columnName is constrained to be NOT NULL
and T is not on the right/left side of a left/right outer join. In
other cases, you would choose the one that gives you the answer you
want, and you wouldn't choose to calculate a different answer because
it's faster, but even if you had a choice, count(*) will probably be
faster than count(columnName), unless there is something strange about
the table data or statistics that leads the optimizer to a bad query
plan and that has nothing to do with the count() aggregate.
Steve Kass
Drew University
Roji. P. Thomas wrote:
>Enric,
>
> SELECT Count(*)
> is equivalent to
>
> SELECT COUNT('AnythingGoesHere')
>
> But SELECT COUNT(fieldName) can give you better results
> (also different results dependas on the NULLability), based on the
> indexes available.
>
> See :
>http://toponewithties.blogspot.com/2004/08/count-vs-countcolname.html
>
>
- Next message: Tudor Sofron: "Dynamic sql"
- Previous message: Scott Ivey: "Re: [DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."
- In reply to: Roji. P. Thomas: "Re: just a silly thing maybe..."
- Next in thread: Uri Dimant: "Re: just a silly thing maybe..."
- Reply: Uri Dimant: "Re: just a silly thing maybe..."
- Reply: Itzik Ben-Gan: "Re: just a silly thing maybe..."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|