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 ...
随机推荐
- BIND9源码学习笔记1---gdb调试篇
学习bind9源码之前,首先要知道如何用gdb来调试bind.BIND9的源码我是先看代码弄懂它的架构,像什么event-drive,epoll等, 再去看它的业务流程.看业务流程的时候要追踪它的数据 ...
- 如何修改Oracle用户密码
大家如果不知道oracle数据库的密码的话,我们可以通过简单的命令行把密码进行修改. 1.打开cmd 2 在弹出的命令提示窗口输入 set oracle_sid=数据库名称(实例),回车.例如数据库名 ...
- 关于LOAD DATA INFILE 命令的使用问题解决
通过LOAD DATA方式将数据导入数据表中 LOAD DATA INFILE '输入文件的路径及文件名' INTO TABLE 要导入表的表名称; LOAD DATA INFILE 'G:/p.tx ...
- SVN权限修复
Description : Commit failed (details follow): Suggestion : The operation could not be completed. Tec ...
- android后台截屏实现(1)--源码编译
前段时间接到任务要实现后台截图并上传的功能,在网上查了好久,发现遇到这类问题的人还不少.经过一番对比后发现还是修改并编译源码中的screencap类然后通过JNI来调用这种方法比较可靠,而其他的在ja ...
- Python 获取Facebook用户的Friends的爱好中的Top10
CODE; #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-12 @author: guaguastd @name: f ...
- linux下mysql的卸载、安装全过程
卸载mysql 1.查找以前是否装有mysql 命令:rpm -qa|grep -i mysql 可以看到mysql的两个包: mysql-4.1.12-3.RHEL4.1 mysqlclient10 ...
- event.getAction()&MotionEvent.ACTION_MASK的原因
看到下面代码中用了AND位运算是为了什么呢? public boolean onTouchEvent(MotionEvent event) { int action = event.getAction ...
- Mysql数据库的mysql Schema 究竟有哪些东西& 手工注入的基础要领
#查看数据库版本号 mysql> select @@version; +------------+ | @@version | +------------+ | 5.5.16-log | +- ...
- 获取checkboxlist选中的值以及绑定来自之前选中的来自数据库的值
//////ps:一下几句都是一个意思,为的是以后有人搜索关键字的时候能定位到这里///checkboxlist绑定选中值///checkboxlist绑定来之mssql数据的值///checkbox ...