Are you asking if Select count(theFieldName) is faster than select count(*)?
I agree with you, I think the performance should be similar.
On the other hand, on tables with more than one field,
select theFieldName
should always be marginally faster than
select *
Simply due to the amount of data being returned.
More often than not, the convenience of having all of your data fields handy will outweigh the marginal performance increase.
November 29th, 2008
William
count(1) should be more efficient. 1 is an integer (can be any integer) - and shouldn’t require a fetch of data from the result set for matching rows.
Note: count(column_name) will only count non-null results.
Interestingly - a sql server MVP states that this is a PL/SQL failing - and T-SQL’s optimizer will catch it… (although my pref would be to help out the optimizer when possible):
2 Comments, Comment or Ping
Are you asking if Select count(theFieldName) is faster than select count(*)?
I agree with you, I think the performance should be similar.
On the other hand, on tables with more than one field,
select theFieldName
should always be marginally faster than
select *
Simply due to the amount of data being returned.
More often than not, the convenience of having all of your data fields handy will outweigh the marginal performance increase.
November 29th, 2008
count(1) should be more efficient. 1 is an integer (can be any integer) - and shouldn’t require a fetch of data from the result set for matching rows.
Note: count(column_name) will only count non-null results.
Interestingly - a sql server MVP states that this is a PL/SQL failing - and T-SQL’s optimizer will catch it… (although my pref would be to help out the optimizer when possible):
http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/9367c580-087a-4fc1-bf88-91a51a4ee018/
December 30th, 2008
Reply to “what’s faster?”