性能问题select Count(*) from table 有 100 条数据 那么用 select Count(*) from table 查出总数量 还是 算快的如果 有 5000000 条数据 select Count(*) from table 就很慢了 ;; 请问有没有 办法使它 执行更快!! 谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 本以为select count(1) from table 会快点,结果是慢了... 我的是400多万,查出来还不到1秒, 这个速度应该还可以接受吧,如果楼主想继续提高,可以提高硬件...SQL> set timing onSQL> select count(*) from customer; COUNT(*)---------- 4343867已用时间: 00: 00: 00.64SQL> select count(1) from customer; COUNT(1)---------- 4343871已用时间: 00: 00: 00.79SQL> 索引很重要,建好了索引 类似的count操作应该很快的~ 那你试试select Count(rid) from table 的性能如何 参考一下这个帖以前vc555大侠详细介绍过一次的http://topic.csdn.net/u/20090617/16/401ea743-48fa-4449-ab85-6e955fea1a01.html select count(*) from table是不走索引的。因为在null值上不存在索引!如果你想我加快select count(*) from table 的速度,只有利用Oracle的并行执行!select /* +parallel(table,5)*/count(*) from table这个是以消耗cpu资源为代价的,如果cup占用率高,那就别用。表中数据越多,速度越明显!!!! 没有条件,建索引也不会走呀select count(主键字段) from tablename SELECT COUNT(ROWID) FROM TABLE, try 可以建立索引,简单的方法就是 select count(列名) from Table 这样也是比较有效的,我感觉在操作数据库时无论什么语句最好别用* \mysql> select count(*) from mytable;+----------+| count(*) |+----------+| 973442 |+----------+1 row in set (2.84 sec)mysql> select count(name) from mytable;+-------------+| count(name) |+-------------+| 973442 |+-------------+1 row in set (3.33 sec)那 这 是 怎么回事 啊 !! 不是说 * 是 很慢的么 我感觉在操作数据库时无论什么语句最好别用*=============================================country(*) 和 count(name) 结果是不一样的。 看上面的好像count(*)比count(1)是间要快啊,为什么啊? 对啊 我也 不知道 为什么呢 ?? count(name ) 是我 建的 索引 列 等待 高手!!! select Count(*) from table这个语句建个索引能提高性能吗? select count(rowid) for table还有如果建立索引但没有条件只是count(索引)有效果吗 试过了,time :count(rowid)< count(*) <count(1) time :count(关键字)<count(rowid) < count(*) <count(1) 请问在plsql中,创建子程序(过程,函数)是在哪里创建? 为什么 dblinks 无效!! 加密系统函数包受损,如何恢复? informix create view 问题 谢谢大家! oracle 中的键保留表 安装Oracle10121遇到的问题? 数据导入库的问题?? oracle安装问题!! 导出数据问题 java 连接 oracle 需要配置点什么啊? 在linux下安装了oracle,使用“./dbstart”启动数据库,为何报错?cat: /var/opt/oracle/oratab: 没有那个文件或目录
我的是400多万,查出来还不到1秒, 这个速度应该还可以接受吧,如果楼主想继续提高,可以提高硬件...SQL> set timing on
SQL> select count(*) from customer; COUNT(*)
----------
4343867已用时间: 00: 00: 00.64
SQL> select count(1) from customer; COUNT(1)
----------
4343871已用时间: 00: 00: 00.79
SQL>
的性能如何
http://topic.csdn.net/u/20090617/16/401ea743-48fa-4449-ab85-6e955fea1a01.html
是不走索引的。因为在null值上不存在索引!
如果你想我加快select count(*) from table 的速度,只有利用Oracle的并行执行!
select /* +parallel(table,5)*/count(*) from table
这个是以消耗cpu资源为代价的,如果cup占用率高,那就别用。
表中数据越多,速度越明显!!!!
select count(主键字段) from tablename
这样也是比较有效的,我感觉在操作数据库时无论什么语句最好别用*
mysql> select count(*) from mytable;
+----------+
| count(*) |
+----------+
| 973442 |
+----------+
1 row in set (2.84 sec)mysql> select count(name) from mytable;
+-------------+
| count(name) |
+-------------+
| 973442 |
+-------------+
1 row in set (3.33 sec)那 这 是 怎么回事 啊 !! 不是说 * 是 很慢的么
=============================================
country(*) 和 count(name) 结果是不一样的。
这个语句建个索引能提高性能吗?