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 ...
随机推荐
- Oracle Berkeley DB Java 版
Oracle Berkeley DB Java 版是一个开源的.可嵌入的事务存储引擎,是完全用 Java 编写的.它充分利用 Java 环境来简化开发和部署.Oracle Berkeley DB Ja ...
- 简析MFC中CString用作C字符串
MFC中CString是一个方便的字符串操作的类, 然而很多函数需要传递字符指针, 这就需要进行CString和普通字符串的转换. 1.CString用作C字符串常量. 直接使用强制类型转换即可, ...
- Python-字符串开头或结尾匹配
startswith() 和 endswith() 方法提供了一个非常方便的方式去做字符串开头和结尾的检查. 1.查看指定目录下的所有文件名 >>> import os >&g ...
- 编译lua5.3.2报错提示libreadline.so存在未定义的引用解决方法
从官网上下载5.3.2的源码后,make linux进行编译,提示报错: gcc -std=gnu99 -o lua lua.o liblua.a -lm -Wl,-E -ldl -lreadline ...
- mybatis之特殊查询
在mybatis查询的过程中,某个字段是经过计算得到的,这时,在设计数据表的时候,就不 必在增加此对应的字段 那么,在查询的时候,页面有需要展示这个字段时,怎么办呢? 举个例子: 在查询微信团商品时, ...
- NHibernate——基本映射(5)
一.映射定义概括 1.1 映射定义(Mapping declaration) 对象和关系数据库之间的映射是用一个XML文档(XML document)来定义的.这个映射文档被设计为易读的,并且可以手工 ...
- C#小写人民币转大写
public string GetRMB(decimal moneyAmount) { string s = moneyAmount.ToString("#L#E#D#C#K#E#D#C#J ...
- easyui之combobox(不定时补充)
1,combobox的valuefeild和textfeild这两个属性,可以理解为键值对,即:键valuefeild:值textfeild textfeild是文本框内显示的值,如果要取文本框内的值 ...
- Say bye to CMake and Makefile
用了几年的CMake,最近想试着琢磨如何将C++应用的动态链接全部改成静态链接,发现还需要研究CMake的用法,进入CMake的文档, http://www.cmake.org/cmake/help/ ...
- asp.net 的那点事(2、浏览器和一般处理程序)
从今天开始我们接着来学习:asp.net中一般处理程序和浏览器的通信. 一.第一个图解: 从图解中我们看出,整个过程是:"请求---处理---响应".这个也就是经常面试的时候,面试 ...