DBAs have told me that when using T-SQL:
select count(id) from tableName
is faster than
select count(*) from tablenName
if id is the primary key.
Extrapolating that to LINQ-TO-SQL is the following accurate?
This LINQ-to-SQL statement:
int count = dataContext.TableName.Select(primaryKeyId => primaryKeyId).Count();
is more performant than this one:
int count = dataContext.TableName.Count();
count(1)
would be, potentially, even better. However, re your final "is more performant" question - have you tried it? in particular, trap the SQL used for both queries, see if that is different. If it is different, run it both ways with stats-io enabled, etc.