您当前的位置: 首页 >  sql

[MSSQL]Select count(*)与Select count(字段)的效率分析

发布时间:2012-03-06 14:02:33 ,浏览量:0

原文:

Advice on using COUNT( ) In the SQL Server community, one thing that I sometimes encounter is the question on whether you should use COUNT(*) or COUNT(columnname), where columnname is a column in the table that you want to count the rows for. Often the advice given to people in forums and mailing lists is that COUNT(columnname) will perform better than COUNT(*). This is not always the correct advice though, in many cases it is even entirely wrong. Although there are situations where you can (or even should) use COUNT(columnname), you definitely shouldn't always use it. This incorrect piece of advice is probably based on a lack of understanding of how SQL Server handles data internally. 

Description of COUNT( ) The first thing that you need to know is that there is a difference between the alternative ways of using COUNT( ), and what this difference is. The complete syntax for COUNT( ) is this:

  COUNT ( { [ ALL | DIST

关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    106485博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0484s