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.
| Author |
Topic |
|
kmarshba
Starting Member
24 Posts |
Posted - 2003-10-10 : 15:22:04
|
| I know count(1) is faster but am having a hard time locating some real documentation on why.Does anyone have an answer to this? I'm wondering if it is only faster because it is counting a constant. Is it better to count a column in the clustered index? My query plan shows it is counting the clustered index even with count(*).Thanks! |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-10 : 15:43:00
|
| It's not.SQL server is specifically optimised for count(*) and I prefer that notation.count(*) will count rows from the best index available - just like count(1).I believe there other lesser databases where count(1) is more efficient :).==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
kmarshba
Starting Member
24 Posts |
Posted - 2003-10-10 : 16:25:36
|
| Thanks nr!Now to find out the source of that misconception.Kevin |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-10-10 : 17:27:59
|
| I've seen it stated for Oracle (even in books) but pretty sure it's not true.The only thing to avoid is count(colname) unless that's what you need.count(*) is the best cos I say so.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|