本帖最后由 dotaddjj 于 2014-8-25 11:38 编辑
我个人认为这两个sql没有可比性,首先第一个sql语句select SUM(origin_value) from ATable这个如果这个列上面有索引,走全索引快速扫描是最优秀的,一般而言索引的大小肯定比表小,那么多块读时段的大小会决定cbo选择那种执行方式,一般是全索引快速扫描,至于你这个为什么没有走该列上面的全索引扫描,个人也比较奇怪,这个对于该列是否有not null约束没影响的,因为null值sum后结果也不会变。
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Aug 25 10:05:29 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select sum(object_id) from ta;
Execution Plan
----------------------------------------------------------
Plan hash value: 1383641628
-----------------------------------------------------------------