zoukankan      html  css  js  c++  java
  • count(1) count(*)

    mysql> select 1 from t;
    +---+
    | 1 |
    +---+
    | 1 |
    | 1 |
    | 1 |
    | 1 |
    +---+
    4 rows in set (0.00 sec)
    mysql> select count(1) from t;    
    +----------+
    | count(1) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> select count(*) from t; 
    +----------+
    | count(*) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> select count(a) from t; 
    +----------+
    | count(a) |
    +----------+
    |        4 |
    +----------+
    1 row in set (0.00 sec)
    mysql> explain  extended SELECT count(*) FROM `employees`;
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    | id | select_type | table     | type  | possible_keys | key     | key_len | ref  | rows   | filtered | Extra       |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    |  1 | SIMPLE      | employees | index | NULL          | PRIMARY | 4       | NULL | 299689 |   100.00 | Using index |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    1 row in set, 1 warning (0.17 sec)
    
    mysql> show warnings;
    +-------+------+---------------------------------------------------------------------------+
    | Level | Code | Message                                                                   |
    +-------+------+---------------------------------------------------------------------------+
    | Note  | 1003 | /* select#1 */ select count(0) AS `count(*)` from `employees`.`employees` |
    +-------+------+---------------------------------------------------------------------------+
    1 row in set (0.17 sec)
    
    mysql> explain  extended SELECT count(1) FROM `employees`; 
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    | id | select_type | table     | type  | possible_keys | key     | key_len | ref  | rows   | filtered | Extra       |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    |  1 | SIMPLE      | employees | index | NULL          | PRIMARY | 4       | NULL | 299689 |   100.00 | Using index |
    +----+-------------+-----------+-------+---------------+---------+---------+------+--------+----------+-------------+
    1 row in set, 1 warning (0.00 sec)
    
    mysql> show warnings;
    +-------+------+---------------------------------------------------------------------------+
    | Level | Code | Message                                                                   |
    +-------+------+---------------------------------------------------------------------------+
    | Note  | 1003 | /* select#1 */ select count(1) AS `count(1)` from `employees`.`employees` |
    +-------+------+---------------------------------------------------------------------------+
    1 row in set (0.00 sec)
  • 相关阅读:
    SpringBoot+EasyCaptcha实现验证码功能
    Spring boot集成Swagger
    Swagger注释API :@ApiModel
    lombok的@Accessors注解3个属性说明
    lombok——@EqualsAndHashCode(callSuper = true)注解的使用
    Springboot集成分页插件PageHelper
    SprinBoot application.properties配置详情之DataSource
    SpringBoot系列之banner.txt (转)
    C语言基础知识汇总
    Byte、KB、MB、GB、TB、PB、EB是啥以及它们之间的进率
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5635908.html
Copyright © 2011-2022 走看看