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)

count(1) count(*)的更多相关文章

  1. Select count(*)和Count(1)的区别和执行方式

        在SQL Server中Count(*)或者Count(1)或者Count([列])或许是最常用的聚合函数.很多人其实对这三者之间是区分不清的.本文会阐述这三者的作用,关系以及背后的原理.   ...

  2. Count(*)或者Count(1)或者Count([列]) 区别

    在SQL 中Count(*)或者Count(1)或者Count([列])或许是最常用的聚合函数.很多人其实对这三者之间是区分不清的.本文会阐述这三者的作用,关系以及背后的原理. 往常我经常会看到一些所 ...

  3. SQL语句中count(1)count(*)count(字段)用法的区别

    SQL语句中count(1)count(*)count(字段)用法的区别 在SQL语句中count函数是最常用的函数之一,count函数是用来统计表中记录数的一个函数, 一. count(1)和cou ...

  4. count(*) vs count(1)--social.msdn.microsoft.com

    Clever response Dave, but insufficient. I'll admit I've suggested this myself for certain questions ...

  5. count(*)、count(val)和count(1)的解释

    一.关于count的一些谣言: 1.count(*)比count(val)更慢!项目组必须用count(val),不准用count(*),谁用扣谁钱! 2.count(*)用不到索引,count(va ...

  6. 【MySQL】技巧 之 count(*)、count(1)、count(col)

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

  7. sql中count(*)和count(字段名)区别

    数据测试:见图 sql 语句见分晓: SELECT COUNT(*) c1 ,COUNT(ADDRESS) c2 FROM test 显而易见,count(*)统计的是结果集的总条数,count(字段 ...

  8. COUNT(*),count(1),COUNT(ALL expression),COUNT(DISTINCT expression) BY Group by

    select column_2,count(column_2) as 'count(column_2)' ,count(column_1) as 'count(column_1)' ,count(*) ...

  9. COUNT(*),count(1),COUNT(ALL expression),COUNT(DISTINCT expression)

    创建一个测试表 IF OBJECT_ID( 'dbo.T1' , 'U' )IS NOT NULL BEGIN DROP TABLE dbo.T1; END; GO )); GO INSERT INT ...

  10. SQL Select count(*)和Count(1)的区别和执行方式及SQL性能优化

    SQL性能优化:http://www.cnblogs.com/CareySon/category/360333.html Select count(*)和Count(1)的区别和执行方式 在SQL S ...

随机推荐

  1. [topcoder]SmartWordToy

    广度搜索BFS,要用Queue.还不是很熟,这道题帮助理清一些思绪了.其实这道题是求最短路径,所以BFS遇到第一个就可以返回了,所以后面有些现有大小和历史大小的判断可以省却. 过程中拿数组存step还 ...

  2. APP-FND-01706: Error Updating TABLE_NAME In FND_DOCUMENT_SEQUENCES (文档 ID 338026.1)

    In this Document Symptoms Cause Solution Applies to: Oracle Order Management - Version 11.5.10.0 and ...

  3. @Resource和@Autowired

    @Resource的作用相当于@Autowired,只不过@Autowired按byType自动注入,而@Resource默认按 byName自动注入罢了.@Resource有两个属性是比较重要的,分 ...

  4. bzoj3039

    经典题目不多说 ..,..] of longint;     l,r:..] of longint;     i,j,n,m,ans:longint;     x:char; function max ...

  5. LFS 中文版手册发布:如何打造自己的 Linux 发行版

    您是否想过打造您自己的 Linux 发行版?每个 Linux 用户在他们使用 Linux 的过程中都想过做一个他们自己的发行版,至少一次.我也不例外,作为一个 Linux 菜鸟,我也考虑过开发一个自己 ...

  6. codeigniter实现ajax分页

    <?php /** *417 add 主要是实现ajax分页 **/ class MY_Pagination extends CI_Pagination{ public function __c ...

  7. RMAN综合学习之备份

    rman是最经济实惠的oracle备份工具,在这里做一个rman的整体学习. 文章中大多是rman命令的语法,还是最好做做实验,以便印象深刻,因为大多数数据库的备份就是按时跑脚本,恢复也不是经常能遇到 ...

  8. epub3 in action: epub3文件格式简介

    epub3文件就是一个符合epub3标准,以epub为扩展名的zip压缩文件.epub3标准则是基于html5.css3.svg等web标准以及mathML等来展示内容.下图就是一个简单epub3文件 ...

  9. CLR C++ Set Word CustomDocumentProperties

    // WordIssue.cpp : main project file. #include "stdafx.h" using namespace System; using na ...

  10. 几种流行Webservice框架性能对比

    1      摘要 开发webservice应用程序中离不开框架的支持,当open-open网站列举的就有30多种,这对于开发者如何选择带来一定的疑惑.性能Webservice的关键要素,不同的框架性 ...