sqlserver 关于count(1),count(*)测试
2015-07-29 19:35
260 查看
今天做了一个简单的测试工作
create table test1(col1 int identity(1,1),col2 char(5))
go
insert into test1(col2) select '12345'
go 1000
---插入1000条col2 not null 的数据
insert into test1(col2) select null
go 100
-----插入100条col2 null 的数据
--------test-------------------
select count(1) from test
-----1100
select count(2) from test
-----1100
select count(*) from test
-----1100
select count(col2) from test
-----1000
----------总结----------
(1)count(1),count(*) 速度一样
(2)count 函数统计非 null的行数总和
create table test1(col1 int identity(1,1),col2 char(5))
go
insert into test1(col2) select '12345'
go 1000
---插入1000条col2 not null 的数据
insert into test1(col2) select null
go 100
-----插入100条col2 null 的数据
--------test-------------------
select count(1) from test
-----1100
select count(2) from test
-----1100
select count(*) from test
-----1100
select count(col2) from test
-----1000
----------总结----------
(1)count(1),count(*) 速度一样
(2)count 函数统计非 null的行数总和
相关文章推荐
- mongodb复制集部署
- Mybatis+Oracle批处理
- ORACLE创建IOT(索引组织表)
- 大型数据库迁移方案
- NopCommerce 数据库初始化
- ORACLE创建cluster表
- mysql进阶(十一)外键在数据库中的作用
- MySQL进阶(十一)外键在数据库中的作用
- ORACLE的TX锁和TM锁及解锁
- CentOS6.5安装MongoDB
- mysql添加一个用户
- php apc缓存以及与redis的对比
- redis配置集群
- MySQL 查询分页数据中分组后取每组的前N条记录
- [转]在Excel中使用SQL语句实现精确查询
- #数据库操作tips#执行insert语句,参数太多时将insert语句格式化
- ubuntu-14.04 系统安装mysql-5.6.21
- mongodb与spring整合及基础dao类封装
- 如何查看Oracle数据库表空间大小(空闲、已使用),是否要增加表空间的数据文件
- 并发管理器的工作原理 和 cmclean.sql的潜在危险