oracle 10g下范围分区扫描的几种方式
oracle 10g下有几种扫描方式,注意最后一种扫描方式,当对分区的列进行计算时,会不走分区。这跟对索引列进行计算会导致无法用索引一样。
--扫描单个分区 PARTITION RANGE SINGLE
--连续扫描多个分区 PARTITION RANGE ITERATOR
--不连续扫描多个分区 PARTITION RANGE INLIST
--扫描全分区 PARTITION RANGE ALL
SQL> drop table t_range purge;
SQL> create table t_range (id number not null PRIMARY KEY, test_date date) partition by range (test_date)
(
partition p_1 values less than (to_date('2013-12-01', 'yyyy-mm-dd')),
partition p_2 values less than (to_date('2014-02-01', 'yyyy-mm-dd')),
partition p_3 values less than (to_date('2014-03-01', 'yyyy-mm-dd')),
partition p_4 values less than (to_date('2014-04-01', 'yyyy-mm-dd')),
partition p_5 values less than (to_date('2014-05-01', 'yyyy-mm-dd')),
partition p_6 values less than (to_date('2014-06-01', 'yyyy-mm-dd')),
partition p_max values less than (MAXVALUE)
) nologging;
SQL> insert /*+append */ into t_range select rownum,
to_date(to_char(sysdate - 140, 'J') +
trunc(dbms_random.value(0, 80)),
'J')
from dual
connect by rownum <= 100000;
SQL> commit;
SQL> exec dbms_stats.gather_table_stats(user,'T_RANGE');
SQL> select to_char(t.test_date,'yyyy-MM'),count(1) from t_range t
group by to_char(t.test_date,'yyyy-MM');
TO_CHAR COUNT(1)
------- ----------
2014-01 38803
2014-03 11242
2013-12 15107
2014-02 34848
SQL> set autotrace traceonly
--扫描单个分区
SQL> select * from t_range where test_date = to_date('2014-04-28', 'yyyy-mm-dd');
运行计划
----------------------------------------------------------
Plan hash value: 3010141842
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 22 | 2 (0)| 00:00:01 | | |
| 1 | PARTITION RANGE SINGLE| | 1 | 22 | 2 (0)| 00:00:01 | 5 | 5 |
|* 2 | TABLE ACCESS FULL | T_RANGE | 1 | 22 | 2 (0)| 00:00:01 | 5 | 5 |
--------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("TEST_DATE"=TO_DATE('2014-04-28 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
3 consistent gets
0 physical reads
0 redo size
327 bytes sent via SQL*Net to client
374 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
--连续扫描多个分区
SQL> select * from t_range
where test_date <= to_date('2014-04-28', 'yyyy-mm-dd')
and test_date >= to_date('2014-02-28', 'yyyy-mm-dd');
运行计划
----------------------------------------------------------
Plan hash value: 1921532398
----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 12556 | 147K| 28 (0)| 00:00:01 | | |
| 1 | PARTITION RANGE ITERATOR| | 12556 | 147K| 28 (0)| 00:00:01 | 3 | 5 |
|* 2 | TABLE ACCESS FULL | T_RANGE | 12556 | 147K| 28 (0)| 00:00:01 | 3 | 5 |
----------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("TEST_DATE">=TO_DATE('2014-02-28 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
"TEST_DATE"<=TO_DATE('2014-04-28 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
956 consistent gets
0 physical reads
0 redo size
309138 bytes sent via SQL*Net to client
9515 bytes received via SQL*Net from client
832 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
12453 rows processed
--不连续扫描多个分区
SQL> select * from t_range
where test_date = to_date('2014-04-28', 'yyyy-mm-dd')
or test_date = to_date('2014-02-28', 'yyyy-mm-dd');
运行计划
----------------------------------------------------------
Plan hash value: 2021067984
--------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1678 | 20136 | 21 (0)| 00:00:01 | | |
| 1 | PARTITION RANGE INLIST| | 1678 | 20136 | 21 (0)| 00:00:01 |KEY(I) |KEY(I) |
|* 2 | TABLE ACCESS FULL | T_RANGE | 1678 | 20136 | 21 (0)| 00:00:01 |KEY(I) |KEY(I) |
--------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("TEST_DATE"=TO_DATE('2014-02-28 00:00:00', 'yyyy-mm-dd hh24:mi:ss') OR
"TEST_DATE"=TO_DATE('2014-04-28 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
175 consistent gets
0 physical reads
0 redo size
22646 bytes sent via SQL*Net to client
1265 bytes received via SQL*Net from client
82 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1211 rows processed
--扫描全分区
SQL> select * from t_range where to_char(test_date,'yyyy-MM-dd')='2014-04-01';
运行计划
----------------------------------------------------------
Plan hash value: 2128486036
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 994 | 11928 | 59 (4)| 00:00:01 | | |
| 1 | PARTITION RANGE ALL| | 994 | 11928 | 59 (4)| 00:00:01 | 1 | 7 |
|* 2 | TABLE ACCESS FULL | T_RANGE | 994 | 11928 | 59 (4)| 00:00:01 | 1 | 7 |
-----------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(TO_CHAR(INTERNAL_FUNCTION("TEST_DATE"),'yyyy-MM-dd')='2014-04-01')
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
272 consistent gets
0 physical reads
0 redo size
327 bytes sent via SQL*Net to client
374 bytes received via SQL*Net from client
1 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
0 rows processed
oracle 10g下范围分区扫描的几种方式的更多相关文章
- Solon 开发,四、Bean 扫描的三种方式
Solon 开发 一.注入或手动获取配置 二.注入或手动获取Bean 三.构建一个Bean的三种方式 四.Bean 扫描的三种方式 五.切面与环绕拦截 六.提取Bean的函数进行定制开发 七.自定义注 ...
- Oracle字符串行拆分成列的三种方式
Oracle字符串行拆分成列的三种方式 --muphy 开发过程中经常会遇到将前台多个值用逗号连接一同传递到后台查询,这个用逗号连接的字符串分隔的每个字符串分别对应Oracle数据库表的不同行. 如下 ...
- Oracle实现主键自增的几种方式
数据库作为一个系统的核心,数据库设计的1NF就是一个表结构必须有唯一约束也就是主键,Oracle数据库本身没有自增机制,不像MySQL直接使用关键字AUTO_INCREMENT自动加一,所以需要我们去 ...
- node.js 下依赖Express 实现post 4种方式提交参数
上面这个图好有意思啊,哈哈, v8威武啊.... 在2014年的最后一天和大家分享关于node.js 如何提交4种格式的post数据. 上上一篇说到了关于http协议里定义的4种常见数据的post方法 ...
- 27. Oracle 10g下emctl start dbconsole 报错:OC4J Configuration issue 问题解决
(dbconsole配置好外面的sqlplus才能连的上服务器上的数据库) 采取重新配置emctl 的方法来解决 [oracle@guohuias3 oracle]$ emca -config dbc ...
- Oracle 10g下emctl start dbconsole 报错:OC4J Configuration issue 问题解决
http://blog.sina.com.cn/s/blog_95b5eb8c0100x4a7.html http://blog.csdn.net/sz_bdqn/article/details/17 ...
- eclipse下部署web工程的两种方式
习惯了Eclipse 的开发,就觉得不想那么懒去用MyEclipse傻瓜式的部署工程. 第一种,手动部署工程. 情况一:如果工程目录在tomcat目录的webapp目录下,这种情况就不需要有工程部署的 ...
- liunx下search文件内容的几种方式
第一种.使用vim来search内容 /regex_word,从上到下匹配 ?regex_word,从下到上匹配 n是获取下一个匹配字符串,N是获取上一个匹配字符串. 第二种.使用grep命令 gre ...
- Dynamics CRM 非声明验证方式下连接组织服务的两种方式的性能测试
今天看了勇哥的博文"http://luoyong0201.blog.163.com/blog/static/1129305201510153391392/",又认识到了一种新的连接 ...
随机推荐
- python中pygame模块的Linux下安装过程
一.使用pip安装Python包 大多数较新的Python版本都自带pip,因此首先可检查系统是否已经安装了pip.在Python3中,pip有时被称为pip3. 1.在Linux和OS X系统中检查 ...
- 利用 bat 批量处理命令实现手动控制mysql /Oracle 服务的开启和关闭
利用 bat 批量处理命令实现手动控制mysql /Oracle 服务的开启和关闭 因为最近在学习数据库的知识,主要学习的是oracle 数据库,然而好巧啊,java也是在学习,我们老师现在要我们做一 ...
- SqlServer 数据库附加问题:不是主数据库文件
一.前言 今天公司要切换数据库服务器,数据库文件大于2G,结果再附加到另一服务器的数据库里面,就产生了一个问题.如下: 标题:Microsoft SQL Server Management Studi ...
- 【Kafka源码】broker被选为controller之后的连锁反应
[TOC] 今天我们主要分析下broker被选为controller之后,主要干了什么.门面代码先列出来: def onControllerFailover() { if (isRunning) { ...
- Java设计模式相关面试
1.接口是什么?为什么要使用接口而不是直接使用具体类? 接口用于定义 API.它定义了类必须得遵循的规则.同时,它提供了一种抽象,因为客户端只使用接口,这样可以有多重实现,如 List 接口,你可以使 ...
- app.config 配置多项 配置集合 自定义配置(2)
上一篇说了利用app.config自定义节点配置,那是利用工具来实现,其实也一全部编码的方式来实现.举一个栗子.Simpson一家有父亲James,母亲Kate,和三个儿女Jim,Aaron和Luka ...
- C#实现中国身份证验证问题
C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准... 今天写的 C#中国身份证验证,包括省份验证和校验码验证,符合GB11643-1999标准... 理论部分: 1 ...
- VPN连接机器不再输入密码以及Pin码方法
连接机器不输入密码 #!/usr/bin/env expect spawn ssh guosong@xx_ip; expect "*password*"; send &quo ...
- Python [习题] 字典排序
[习题] 对此字典分别按照value 和key 如何排序? dic1 = {'and':40, 'a':54, 'is':60, 'path':139, 'the':124, 'os':49} In ...
- SHA安全散列算法简析
1 SHA算法简介 1.1 概述 SHA (Secure Hash Algorithm,译作安全散列算法) 是美国国家安全局 (NSA) 设计,美国国家标准与技术研究院(NIST) 发布的一系列密码散 ...