select count(*) from T 可以用到索引吗?
来源:互联网 发布:java面试自我评价 编辑:程序博客网 时间:2024/06/05 00:42
1、如果索引列有非空约束,则可以用到索引;
2、或者采用 select count(*) from T where 索引列 is not null;也可以用到索引,即使索引列没有非空约束。
当表字段很多,并且字段长度大多很长,这时如果在一个非空且长度很短的列建一个索引,这时索引的体积相对表来说很小,那么索引读的效率就高很多;
sum(索引列)和avg(索引列)和count(*)同理,都要注意非空问题;
min(索引列)和max(索引列)则不需要考虑空值问题;
select max(索引列),min(索引列) from t;
如果索引列没有非空约束,则走全表扫描;如果索引列有非空约束,则走INDEX FAST FULL SCAN
select max, min
from (select max(索引列) max from t ) a,
(select min(索引列) min from t ) b;
走INDEX FULL SCAN (MIN/MAX)更高效
0 0
- select count(*) from T 可以用到索引吗?
- hive可以执行select * from table;“ 却无法执行"select count(*) from table;"
- 通过非聚集索引让select count(*) from 的查询速度提高几十倍、甚至千倍
- 通过非聚集索引让select count(*) from 的查询速度提高几十倍、甚至千倍
- 通过非聚集索引让select count(*) from 的查询速度提高几十倍、甚至千倍
- 通过非聚集索引让select count(*) from 的查询速度提高几十倍、甚至千倍
- 通过非聚集索引让select count(*) from 的查询速度提高几十倍、甚至千倍
- select count(column_name) form table_name or select count(*) from table_Name
- select * from 与select count(*) from 的区别
- Select count(*) from与Select * from的区别
- select count(id) from table 返回值
- 使用JDBC获取select count(*) from table_name
- select count(*) from temp 与select count(1) from temp有什么区别
- select * from table_name for update; 和 select t.*, t.rowid from table_name t的区别
- select * from t 和select * from t order by id两个有什么区别
- Hive SQL 语义分析:select count(*) from tableName
- hive中运行 select count(1) from test报错
- select count from multiple tables(多表计数查询)
- Memcached全面剖析–4. memcached的分布式算法
- gt ge lt le ne 缩写 的 英文 含义
- 表视图的基本概念和用法
- Linux Shell编程入门
- maven之findbugs插件
- select count(*) from T 可以用到索引吗?
- PC架构系列:CPU/RAM/IO总线的发展历史!
- iframe的使用方法,嵌入网页。
- Eclipse搭建Android开发环境(安装ADT,Android4.4.2)
- FFmpeg 收藏的资源
- Visual Studio "无法查找或打开PDB文件"解决方法
- [转载]Linux 查看文件修改时间(精确到秒)
- sybase中的聚簇索引与count(*)的关系
- [LeetCode] Permutations