<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扩展的更多相关文章

  1. Asp.net Boilerplate之AbpSession扩展

    当前Abp版本1.2,项目类型为MVC5. 以属性的形式扩展AbpSession,并在"记住我"后,下次自动登录也能获取到扩展属性的值,版权归"角落的白板报"所 ...

  2. 恢复SQL Server被误删除的数据(再扩展)

    恢复SQL Server被误删除的数据(再扩展) 大家对本人之前的文章<恢复SQL Server被误删除的数据> 反应非常热烈,但是文章里的存储过程不能实现对备份出来的日志备份里所删数据的 ...

  3. .NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法

    .NET Core中间件的注册和管道的构建(3) ---- 使用Map/MapWhen扩展方法 0x00 为什么需要Map(MapWhen)扩展 如果业务逻辑比较简单的话,一条主管道就够了,确实用不到 ...

  4. .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类

    .NET Core中间件的注册和管道的构建(2)---- 用UseMiddleware扩展方法注册中间件类 0x00 为什么要引入扩展方法 有的中间件功能比较简单,有的则比较复杂,并且依赖其它组件.除 ...

  5. 采用EntityFramework.Extended 对EF进行扩展(Entity Framework 延伸系列2)

    前言 Entity Framework 延伸系列目录 今天我们来讲讲EntityFramework.Extended 首先科普一下这个EntityFramework.Extended是什么,如下: 这 ...

  6. Dapper扩展之~~~Dapper.Contrib

    平台之大势何人能挡? 带着你的Net飞奔吧!http://www.cnblogs.com/dunitian/p/4822808.html#skill 上一篇文章:Dapper逆天入门~强类型,动态类型 ...

  7. ExtJS 4.2 Date组件扩展:添加清除按钮

    ExtJS中除了提供丰富的组件外,我们还可以扩展他的组件. 在这里,我们将在Date日期组件上添加一个[清除]按钮,用于此组件已选中值的清除. 目录 1. Date组件介绍 2. 主要代码说明 3. ...

  8. .NET Core的文件系统[5]:扩展文件系统构建一个简易版“云盘”

    FileProvider构建了一个抽象文件系统,作为它的两个具体实现,PhysicalFileProvider和EmbeddedFileProvider则分别为我们构建了一个物理文件系统和程序集内嵌文 ...

  9. Hawk 6. 编译和扩展开发

    Hawk是开源项目,因此任何人都可以为其贡献代码.作者也非常欢迎使用者能够扩展出更有用的插件. 编译 编译需要Visual Stuido,版本建议使用2015, 2010及以上没有经过测试,但应该可以 ...

  10. 为IEnumerable<T>添加RemoveAll<IEnumerable<T>>扩展方法--高性能篇

    最近写代码,遇到一个问题,微软基于List<T>自带的方法是public bool Remove(T item);,可是有时候我们可能会用到诸如RemoveAll<IEnumerab ...

随机推荐

  1. HDU_2028——求多个数的最小公倍数

    Problem Description 求n个数的最小公倍数.   Input 输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.   Output 为每组测试数据输出它们的最 ...

  2. linux系统下mySQL数据库 备份方法和脚本

    数据库备份1.创建个备份存储目录mkdir /root/backup/2.以下内容写到dbbackup.sh #!/bin/bash cd /data/db_backup/mysqldump -uad ...

  3. Android笔记(三):View一些值得注意的地方

    Button android:textAllCaps="false" // Button上的英文字符不转成大写 EditText android:maxLines="2& ...

  4. Hive和HBase的区别

    一.两者分别是什么:     Apache Hive是一个构建在Hadoop基础设施之上的数据仓库.通过Hive可以使用HQL语言查询存放在HDFS上的数据.HQL是一种类SQL语言,这种语言最终被转 ...

  5. xml to json

    // Changes XML to JSONfunction xmlToJson(xml) {    // Create the return object    var obj = {};    i ...

  6. .net 面试题(3)

    96.题目: 活期存款中,"储户"通过"存取款单"和"储蓄所"发生联系.假定储户包括:账号,姓名,电话,地址,存款额:"储蓄所&q ...

  7. php中socket的使用 方法简介

    一.开启socket phpinfo();查看是否开启了socket扩展,否则在php.ini中开启. 二.服务器端代码的写法 <?php error_reporting(E_ALL); set ...

  8. Android Studio使用教程(一)

    今年的Google全球开发者大会虽然没有新的Android系统和设备,但是还是推出了一些不错的产品,Android Studio就是其中之一.这个基于Intellij IDEA开发的Android I ...

  9. Android(java)学习笔记260:JNI之native方法头文件的生成

    1. JDK1.6 ,进入到工程的bin目录下classes目录下: 使用命令: javah  packageName.ClassName 会在当前目录下生成头文件,从头文件找到jni协议方法 下面举 ...

  10. PLSQL Developer安装(Oracle11g+win7_64bit)

    1)安装Oracle 11g 64位 2)安装32位的Oracle客户端( instantclient-basic-win32-11.2.0.1.0)下载地址:http://www.oracle.co ...