OR扩展
<pre name="code" class="sql">SQL> select substr(xx.acct_no,1,5) agent_org, xx.vou_kind,sum( xx.trans_amt) trans_amt
from (
select * from dwf.F_EVT_SAVD_LIST
where trans_date >= to_date('2013-10-10', 'YYYY-MM-DD')
AND trans_date <= to_date('2014-03-31', 'YYYY-MM-DD')
) xx
where ( xx.vou_kind in ('3', '4')
or
( xx.vou_kind ='188' and xx.trans_code in ('100201','105301') )
)
and xx.dc_flag = '1'
group by substr(xx.acct_no,1,5), xx.vou_kind,xx.vou_no,xx.trans_date ; 2 3 4 5 6 7 8 9 10 11 12 19781 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 3813767548 -------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 38474 | 2893K| 1663 (1)| 00:00:20 |
| 1 | HASH GROUP BY | | 38474 | 2893K| | |
| 2 | CONCATENATION | | | | | |
| 3 | INLIST ITERATOR | | | | | |
|* 4 | TABLE ACCESS BY INDEX ROWID| F_EVT_SAVD_LIST | 1 | 77 | 7 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | F_EVT_SAVD_LIST_IDX1 | 7 | | 5 (0)| 00:00:01 |
| 6 | INLIST ITERATOR | | | | | |
|* 7 | TABLE ACCESS BY INDEX ROWID| F_EVT_SAVD_LIST | 38473 | 2892K| 961 (1)| 00:00:12 |
|* 8 | INDEX RANGE SCAN | F_EVT_SAVD_LIST_IDX1 | 1781 | | 673 (1)| 00:00:09 |
------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 4 - filter("F_EVT_SAVD_LIST"."DC_FLAG"='1')
5 - access("F_EVT_SAVD_LIST"."VOU_KIND"='188' AND ("F_EVT_SAVD_LIST"."TRANS_CODE"='100201'
OR "F_EVT_SAVD_LIST"."TRANS_CODE"='105301') AND "TRANS_DATE">=TO_DATE(' 2013-10-10 00:00:00',
'syyyy-mm-dd hh24:mi:ss') AND "TRANS_DATE"<=TO_DATE(' 2014-03-31 00:00:00', 'syyyy-mm-dd
hh24:mi:ss'))
7 - filter("F_EVT_SAVD_LIST"."DC_FLAG"='1')
8 - access(("F_EVT_SAVD_LIST"."VOU_KIND"='3' OR "F_EVT_SAVD_LIST"."VOU_KIND"='4') AND
"TRANS_DATE">=TO_DATE(' 2013-10-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"TRANS_DATE"<=TO_DATE(' 2014-03-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
filter("TRANS_DATE">=TO_DATE(' 2013-10-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
"TRANS_DATE"<=TO_DATE(' 2014-03-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
(LNNVL("F_EVT_SAVD_LIST"."VOU_KIND"='188') OR LNNVL("F_EVT_SAVD_LIST"."TRANS_CODE"='100201')
AND LNNVL("F_EVT_SAVD_LIST"."TRANS_CODE"='105301'))) Note
-----
- dynamic sampling used for this statement (level=2) Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
20833 consistent gets
0 physical reads
0 redo size
526389 bytes sent via SQL*Net to client
15021 bytes received via SQL*Net from client
1320 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
19781 rows processed CONCATENATION作用:进行扩展就是进行了union改写 使用NO_EXPAND:
阻止扩展 SQL> select /*+ NO_EXPAND*/ substr(xx.acct_no,1,5) agent_org, xx.vou_kind,sum( xx.trans_amt) trans_amt
from (
select * from dwf.F_EVT_SAVD_LIST
where trans_date >= to_date('2013-10-10', 'YYYY-MM-DD')
AND trans_date <= to_date('2014-03-31', 'YYYY-MM-DD')
) xx
where ( xx.vou_kind in ('3', '4')
or
( xx.vou_kind ='188' and xx.trans_code in ('100201','105301') )
)
and xx.dc_flag = '1'
group by substr(xx.acct_no,1,5), xx.vou_kind,xx.vou_no,xx.trans_date ; 2 3 4 5 6 7 8 9 10 11 12 19781 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 1587974759 ------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 38473 | 2892K| | 261K (1)| 00:52:21 |
| 1 | HASH GROUP BY | | 38473 | 2892K| | 261K (1)| 00:52:21 |
|* 2 | TABLE ACCESS BY INDEX ROWID | F_EVT_SAVD_LIST | 38473 | 2892K| | 261K (1)| 00:52:21 |
| 3 | BITMAP CONVERSION TO ROWIDS | | | | | | |
| 4 | BITMAP OR | | | | | | |
| 5 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 6 | SORT ORDER BY | | | | 15M| | |
|* 7 | INDEX RANGE SCAN | F_EVT_SAVD_LIST_IDX1 | | | | 676 (1)| 00:00:09 |
| 8 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 9 | SORT ORDER BY | | | | 15M| | |
|* 10 | INDEX RANGE SCAN | F_EVT_SAVD_LIST_IDX1 | | | | 676 (1)| 00:00:09 |
| 11 | BITMAP CONVERSION FROM ROWIDS| | | | | | |
| 12 | SORT ORDER BY | | | | 15M| | |
|* 13 | INDEX RANGE SCAN | F_EVT_SAVD_LIST_IDX1 | | | | 676 (1)| 00:00:09 |
------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id):
--------------------------------------------------- 2 - filter("F_EVT_SAVD_LIST"."DC_FLAG"='1' AND "TRANS_DATE">=TO_DATE(' 2013-10-10 00:00:00',
'syyyy-mm-dd hh24:mi:ss') AND "TRANS_DATE"<=TO_DATE(' 2014-03-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
7 - access("F_EVT_SAVD_LIST"."VOU_KIND"='3')
filter("F_EVT_SAVD_LIST"."VOU_KIND"='3')
10 - access("F_EVT_SAVD_LIST"."VOU_KIND"='4')
filter("F_EVT_SAVD_LIST"."VOU_KIND"='4')
13 - access("F_EVT_SAVD_LIST"."VOU_KIND"='188')
filter(("F_EVT_SAVD_LIST"."TRANS_CODE"='100201' OR "F_EVT_SAVD_LIST"."TRANS_CODE"='105301') AND
"F_EVT_SAVD_LIST"."VOU_KIND"='188') Note
-----
- dynamic sampling used for this statement (level=2) Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
210065 consistent gets
0 physical reads
0 redo size
548250 bytes sent via SQL*Net to client
15021 bytes received via SQL*Net from client
1320 SQL*Net roundtrips to/from client
3 sorts (memory)
0 sorts (disk)
19781 rows processed 现在走了 BITMAP CONVERSION FROM ROWIDS逻辑读变为210065 ,反而增大 ,静止BITMAP CONVERSION FROM ROWIDS呢? B-tree to Bitmap Conversions
One of the optimizer’s strategies is to range scan B-tree indexes to acquire lists of rowids, convert
the lists of rowids into the equivalent bitmaps, and perform bitwise operations to identify a
small set of rows. Effectively, the optimizer can take sets of rowids from index range scans and
convert them to bitmap indexes on the fly before doing an index_combine on the resulting 优化器的其中一个策略是 Index range scan 得到需要的rowid,转为rowid列表到等效的视图,执行按位运算来确定笑的行集。 实际上,优化器可以取出行集转换为 bitmap indexes bitmap indexes.
In 8i, only tables with existing bitmap indexes could be subject to this treatment, unless
the parameter _b_tree_bitmap_plans had been set to relax the requirement for a preexisting
bitmap index. In 9i, the default value for this parameter changed from false to true—so you may see
execution plans involving bitmap conversions after you’ve upgraded, even though you don’t
have a single bitmap index in your database. Unfortunately, because of the implicit packing
assumption that the optimizer uses for bitmap indexes, this will sometimes be a very bad idea.
As a related issue, this change can make it worth using the minimize_records_per_block
option on all your important tables. SQL> alter session set "_b_tree_bitmap_plans"=false; Session altered. SQL> select /*+ NO_EXPAND*/ substr(xx.acct_no,1,5) agent_org, xx.vou_kind,sum( xx.trans_amt) trans_amt
from (
select * from dwf.F_EVT_SAVD_LIST
where trans_date >= to_date('2013-10-10', 'YYYY-MM-DD')
AND trans_date <= to_date('2014-03-31', 'YYYY-MM-DD')
) xx
where ( xx.vou_kind in ('3', '4')
or
( xx.vou_kind ='188' and xx.trans_code in ('100201','105301') )
)
and xx.dc_flag = '1'
group by substr(xx.acct_no,1,5), xx.vou_kind,xx.vou_no,xx.trans_date ; 2 3 4 5 6 7 8 9 10 11 12 19781 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 2812292261 --------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 38473 | 2892K| 268K (2)| 00:53:47 |
| 1 | HASH GROUP BY | | 38473 | 2892K| 268K (2)| 00:53:47 |
|* 2 | TABLE ACCESS FULL| F_EVT_SAVD_LIST | 38473 | 2892K| 268K (2)| 00:53:47 |
-------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 2 - filter("F_EVT_SAVD_LIST"."DC_FLAG"='1' AND "TRANS_DATE">=TO_DATE('
2013-10-10 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "TRANS_DATE"<=TO_DATE('
2014-03-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND
(("F_EVT_SAVD_LIST"."VOU_KIND"='3' OR "F_EVT_SAVD_LIST"."VOU_KIND"='4') OR
"F_EVT_SAVD_LIST"."VOU_KIND"='188' AND
("F_EVT_SAVD_LIST"."TRANS_CODE"='100201' OR
"F_EVT_SAVD_LIST"."TRANS_CODE"='105301'))) Note
-----
- dynamic sampling used for this statement (level=2) Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
1210345 consistent gets
1210244 physical reads
0 redo size
548290 bytes sent via SQL*Net to client
15021 bytes received via SQL*Net from client
1320 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
19781 rows processed 此时走了全表扫描
OR扩展的更多相关文章
- Asp.net Boilerplate之AbpSession扩展
当前Abp版本1.2,项目类型为MVC5. 以属性的形式扩展AbpSession,并在"记住我"后,下次自动登录也能获取到扩展属性的值,版权归"角落的白板报"所 ...
- 恢复SQL Server被误删除的数据(再扩展)
恢复SQL Server被误删除的数据(再扩展) 大家对本人之前的文章<恢复SQL Server被误删除的数据> 反应非常热烈,但是文章里的存储过程不能实现对备份出来的日志备份里所删数据的 ...
- .NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法
.NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法 0x00 为什么需要Map(MapWhen)扩展 如果业务逻辑比较简单的话,一条主管道就够了,确实用不到 ...
- .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类
.NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类 0x00 为什么要引入扩展方法 有的中间件功能比较简单,有的则比较复杂,并且依赖其它组件.除 ...
- 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)
前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...
- Dapper扩展之~~~Dapper.Contrib
平台之大势何人能挡? 带着你的Net飞奔吧!http://www.cnblogs.com/dunitian/p/4822808.html#skill 上一篇文章:Dapper逆天入门~强类型,动态类型 ...
- ExtJS 4.2 Date组件扩展:添加清除按钮
ExtJS中除了提供丰富的组件外,我们还可以扩展他的组件. 在这里,我们将在Date日期组件上添加一个[清除]按钮,用于此组件已选中值的清除. 目录 1. Date组件介绍 2. 主要代码说明 3. ...
- .NET Core的文件系统[5]:扩展文件系统构建一个简易版“云盘”
FileProvider构建了一个抽象文件系统,作为它的两个具体实现,PhysicalFileProvider和EmbeddedFileProvider则分别为我们构建了一个物理文件系统和程序集内嵌文 ...
- Hawk 6. 编译和扩展开发
Hawk是开源项目,因此任何人都可以为其贡献代码.作者也非常欢迎使用者能够扩展出更有用的插件. 编译 编译需要Visual Stuido,版本建议使用2015, 2010及以上没有经过测试,但应该可以 ...
- 为IEnumerable<T>添加RemoveAll<IEnumerable<T>>扩展方法--高性能篇
最近写代码,遇到一个问题,微软基于List<T>自带的方法是public bool Remove(T item);,可是有时候我们可能会用到诸如RemoveAll<IEnumerab ...
随机推荐
- (转)How to renew your Apple Push Notification Push SSL Certificate
转自:https://blog.serverdensity.com/how-to-renew-your-apple-push-notification-push-ssl-certificate/ It ...
- Matlab生成二类线性可分数据
%% 生成二类线性可分数据 function [feature, category]=generate_sample(step,error) aa=3; %斜率 bb=3; %截距 b1=1; rr ...
- Windows下Hadoop的环境安装[转]
1.下载并安装Cygwin,记得cygwin安装中要把SSH选择上,因为后面Hadoop会用到,不详述cygwin的安装过程.我是安装在D:\cygwin下 2.配置系统环境变量 在windows命令 ...
- web性能优化——JSP
一.啰嗦 做web开发的都知道,性能的重要性就不必强调了.就前端展示的工作来说,jsp大家都熟悉html更熟悉:web服务器tomcat应该是最熟悉的了:web方面的基础知识上来说,静态页面比动态页面 ...
- java基础之导入(药师点评)
/** * 药师点评的导入 * @param request * @param response * @param f * @param tmallTcMessageImport * @return ...
- Angular.js中的$injector服务
一 .angular中的依赖注入 angular的一个很重要的特性就是依赖注入,可以分开理解这4个字. 1.依赖: angular里面的依赖,有angular默认提供的,也有我们自己添加的.默认提供的 ...
- HTML5 Canvas图片操作简单实例1
1.加载显示图片 <canvas id="canvasOne" class="myCanvas" width="500" height ...
- java 修改文件名
// 修改文件名 public static boolean modifyFileName(String serverPath, String oldFileName, String newLogin ...
- IDirect3DDevice9::Clear
在绘制每一帧图形前都要先清空视区,即清空渲染目标表面上的视区矩形的内容:颜色缓冲区.深度缓冲区或者模板缓冲区. HRESULT Clear( [in] DWORD Count, ...
- ZOJ3556 How Many Sets I(容斥)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud How Many Sets I Time Limit: 2 Seconds ...