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/",又认识到了一种新的连接 ...
随机推荐
- 设备类型检测大全---userAgent
对各种类型的设备的检测,以及所使用的浏览器的类型 function detect(ua) { var os = this.os = {}; var browser = this.browser = { ...
- 双色球js
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- win10出现"本地计算机上的MySQL57服务启动后停止"
在window10下mysql57出现"本地计算机上的MySQL57服务启动后停止.某些服务在未由其他服务或程序使用时将自动停止"错误 环境:win10.MySQL Communi ...
- ios -Unity3D的EasyAR集成到已经有项目中。
近期 在做AR这一块,用EasyAR集成到iOS端,由于现在到项目已经上线,下一版本要做一个AR功能,于是迫于需求需要,自己研究和翻阅读好多集成到资料. 通过整理分出几个重要到模块,其中在这里指出Xc ...
- python进阶-------进程线程(二)
Python中的进程线程(二) 一.python中的"锁" 1.GIL锁(全局解释锁) 含义: Python中的线程是操作系统的原生线程,Python虚拟机使用一个全局解释器锁(G ...
- mysql timeout
(待更新整理) 因为最近遇到一些超时的问题,正好就把所有的timeout参数都理一遍,首先数据库里查一下看有哪些超时: root@localhost : test 12:55:50> show ...
- linux下curl的地址使用双引号引用的原因
只知道这么使用,加上双引号,原因不太清楚 原因在于加上双引号可以防止转义,在linux中使用&会使进程后台运行,必须对&进行转义,加反斜杠的方式比较麻烦,故使用双引号模式最方便.
- Liunx vi编辑器一些指令
最近几天学习了Liunx vi编辑器 的使用,感觉还比较容易.总结的一点心得: vi分为3个模式,命令模式,尾行模式,编辑模式. 1. 命令模式 与 编辑模式切换 a:光标向后移动一位进入编辑模式 i ...
- 《Metasploit魔鬼训练营》第四章(上)
p128 wmap 和昨天一样,我用这些漏洞扫描工具去扫testfire.net或者owaspbwa都扫不出漏洞!不明白! 补充:原来是网络不知道啥时候自己断了.连上后再次扫描就成功了:
- NodeJS寻常小毛病
在写关于NodeJS项目中常遇到的小错误 此时用到的服务器是phpstudy中的MySQL 1. First argument must be a string or Buffer 解决方法: ...