Clever response Dave, but insufficient. I'll admit I've suggested this myself for certain questions but I think more is needed here. The OP may run one query where count(*) and count(1) return the same result and have the same performance, but that doesn't mean they always will. Similarly OP could test count(*) and count (<mycolumn>) and get the same performance, so assume they are always the same.

Count(*) and count(1) both just count the number of rows. SQL Server processes them the same way.

 

I know this is not what the OP asked, but just in case you were wondering:

count(*) and count(<mycolumn>) may or not behave the same. Count(<mycolumn>) counts how many rows have VALUES, i.e. are not NULL for <mycolumn>, so SQL Server has to actually look at the column. For count(*) no values need to be examined, and any nonclustered index can be used to quickly determine the count of the rows. For count(<mycolumn>) the actual value in <mycolumn> must be examined, so it could be a lot slower, UNLESS <mycolumn> does not even allow NULLs and then count(<mycolumn>) is identical to count(*)

相关文章:

  • 2021-12-18
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-25
  • 2021-06-11
  • 2021-10-12
  • 2022-12-23
猜你喜欢
  • 2021-12-11
  • 2021-12-10
  • 2021-11-06
  • 2021-10-12
  • 2021-05-31
  • 2021-07-21
  • 2022-12-23
相关资源
相似解决方案