select count(*)、count(数字)、count(字段名)在相同的条件下是没有性能差别的,一般我们在统计行数的时候都会把NULL值统计在内的,所以这样的话,最好就是使用COUNT(*) 和COUNT(1) ,这样的速度最快!!

SET STATISTICS IO ON--查看IO开销
SET STATISTICS PROFILE ON--查看分析、编译和执行查询所需的时间
SET STATISTICS TIME ON--查看语句运行的时间

可以参照这篇文章:http://www.cnblogs.com/lyhabc/p/3376222.html

select count(*)和select count(1)哪个性能高的更多相关文章

  1. select count(*)和select count(1)的区别 (转)

    A 一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键 ...

  2. Select count(*)、Count(1)、Count(0)的区别和执行效率比较

    记得很早以前就有人跟我说过,在使用count的时候要用count(1)而不要用count(*),因为使用count(*)的时候会对所有的列进行扫描,相比而言count(1)不用扫描所有列,所以coun ...

  3. select * 和select 1 以及 select count(*) 和select count(1)的区别

    select 1 和select * select * from 表:查询出表中所有数据,性能比较差: select 常量 from 表:查询出结果是所有记录数的常量,性能比较高: selelct 常 ...

  4. select count(*)和select count(1)

    一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...

  5. select count(*)和select count(1)的区别

    一般情况下,Select Count (*)和Select Count(1)两着返回结果是一样的 假如表沒有主键(Primary key), 那么count(1)比count(*)快, 如果有主键的話 ...

  6. linq 获取不重复数据,重复数据 var unique = arr.GroupBy(o => o).Where(g => g.Count() == 1) .Select(g => g.ElementAt(0));

    static void Main(string[] args) { int[] arr = { 1, 3, 3, 3, 3, 4, 5, 4, 5, 8, 9, 3 }; //不重复 var uniq ...

  7. 提高MSSQL数据库性能(1)对比count(*) 和 替代count(*)

    原文:提高MSSQL数据库性能(1)对比count(*) 和 替代count(*) 文章准备的数据库: Atricles 表   数据量60690000条数据 ArticleID 主键自增列+自动建立 ...

  8. MySql-count(*)与count(id)与count(字段)之间的执行结果和性能分析

    在mysql数据库中,当我们需要统计数据的时候,一定会用到count()这个方法,那么count(值)里面的这个值,到底应该怎么选择呢!常见有3种选择,(*,数字,列名),分别列出它们的执行结果和性能 ...

  9. 图解MySQL:count(*) 、count(1) 、count(主键字段)、count(字段)哪个性能最好?

    大家好,我是小林. 当我们对一张数据表中的记录进行统计的时候,习惯都会使用 count 函数来统计,但是 count 函数传入的参数有很多种,比如 count(1).count(*).count(字段 ...

随机推荐

  1. OpenCV成长之路(9):特征点检测与图像匹配

    特征点又称兴趣点.关键点,它是在图像中突出且具有代表意义的一些点,通过这些点我们可以用来识别图像.进行图像配准.进行3D重建等.本文主要介绍OpenCV中几种定位与表示关键点的函数. 一.Harris ...

  2. Android活动管理工具

    ActivityCollector.java import android.app.Activity; import java.util.ArrayList; import java.util.Lis ...

  3. 7.7---找只含3,5,7的数(CC150)

    ----思路:利用三个队列,一个存3,一个存5,一个存7. 然后,3*3的都放第一个.然后3*5,5*5的放第二个.然后,3*7,5*7,7*7的都放第三个. 答案: public static in ...

  4. 5.3---找最近的两个数(CC150)

    public static int[] getCloseNumber(int x){ int[] res = new int[2]; int i = 1; int num = oneNumber(x) ...

  5. 10. JEB1.5 插件编写二

    一些实例 1. 遍历当前光标处函数所有的Element Java代码: import java.io.*; import java.util.List; import jeb.api.IScript; ...

  6. PL/Cool

    毛子 2003 Petrozavodsk, Final Contest, 8.30.03. G. PL/Cool 实现一个程序,使它读入一段PL/Cool程序,并输出它的结果. PL/Cool语法 b ...

  7. 【leetcode】Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  8. Struts2获取Session方法

    Struts2里面有三种方法可以获取request,最好使用ServletRequestAware接口通过IOC机制注入Request对象. 方法1:IOC方式action类实现SessionAwar ...

  9. ios 后台播放音乐1条注意事项

    除了设置程序的后台模式,还需要几行代码 AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory: ...

  10. jquery 常用的备忘

    1.table 取  tr 的 id值 <table class="table table-striped table-hover table-bordered" id=&q ...