Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select count

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-02-16 : 08:18:59
Roger writes "Hi,

Is doing "select count(1)" more efficient than "select count(*)"?

Roger"

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-16 : 08:29:53
no. exec plans are the same.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-16 : 09:54:20
Uh....WHY would anyone want to select count(1)? I can't imagine what you'd use it for!

Semper fi, Xerxes, USMC(Ret.)
-------------------------------------------------------------------------
Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-16 : 10:22:05
probably because the logic would be: hmmm if i count the column then it must do scan, but if i don't count a column then it won't do a read...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Xerxes
Aged Yak Warrior

666 Posts

Posted - 2005-02-16 : 10:26:02
--- or the logic was "less resources would be used by specifying a target count [1] rather than leaving it to be discovered by the function itself [*]".



Semper fi, Xerxes, USMC(Ret.)
-------------------------------------------------------------------------
Once a Marine Programmer Analyst ALWAYS a Marine Programmer Analyst
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-02-16 : 12:15:27
oh yeah... how could've i forgotten that one???

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -