Dextrys DBA's space
分区表小研究
查看( 119 ) /
评论( 2 )
TAG:
-
kelsoncong
发布于2008-03-17 08:42:00
-
在测试一下,跨越range分区的情况(billing_date_time<'2007-01-01')
SQL> select * from aa where billing_date_time<to_date('2007-01-01','yyyy=mm=dd');
已选择157051行。
执行计划
----------------------------------------------------------
Plan hash value: 3285055242
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 157K| 46M| 1322 (2)| 00:00:16 |
|* 1 | TABLE ACCESS FULL| AA | 157K| 46M| 1322 (2)| 00:00:16 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("BILLING_DATE_TIME"<TO_DATE('2007-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss'))
Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
5 recursive calls
0 db block gets
16184 consistent gets
3904 physical reads
0 redo size
12802601 bytes sent via SQL*Net to client
115555 bytes received via SQL*Net from client
10472 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
157051 rows processed
SQL> select * from hash where billing_date_time<to_date('2007-01-01','yyyy=mm=dd');
已选择157051行。
执行计划
----------------------------------------------------------
Plan hash value: 2064578943
--------------------------------------------------------------------------------
-----------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------
-----------
| 0 | SELECT STATEMENT | | 183K| 54M| 1335 (2)| 00:00:17 | | |
| 1 | PARTITION HASH ALL| | 183K| 54M| 1335 (2)| 00:00:17 | 1 | 4 |
|* 2 | TABLE ACCESS FULL| HASH | 183K| 54M| 1335 (2)| 00:00:17 | 1 | 4 |
--------------------------------------------------------------------------------
-----------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("BILLING_DATE_TIME"<TO_DATE('2007-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
5 recursive calls
0 db block gets
16342 consistent gets
2174 physical reads
0 redo size
13212459 bytes sent via SQL*Net to client
115555 bytes received via SQL*Net from client
10472 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
157051 rows processed
SQL> select * from range where billing_date_time<to_date('2007-01-01','yyyy=mm=dd');
已选择157051行。
执行计划
----------------------------------------------------------
Plan hash value: 2521943314
--------------------------------------------------------------------------------
------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------
------------------
| 0 | SELECT STATEMENT | | 147K| 43M| 850 (2)| 00:00:11 | | |
| 1 | PARTITION RANGE ITERATOR| | 147K| 43M| 850 (2)| 00:00:11 | 1 | 3 |
|* 2 | TABLE ACCESS FULL | RANGE | 147K| 43M| 850 (2)| 00:00:11 | 1 | 3 |
--------------------------------------------------------------------------------
------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("BILLING_DATE_TIME"<TO_DATE('2007-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
1330 recursive calls
2 db block gets
14357 consistent gets
3018 physical reads
264 redo size
12941526 bytes sent via SQL*Net to client
115555 bytes received via SQL*Net from client
10472 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
157051 rows processed
可以明显的看到aa和hash表消耗的成本基本不变,range消耗的成本变成了850
下面看看定值查询的情况
SQL> select * from aa where billing_date_time=to_date('2007-01-01','yyyy=mm=dd');
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 3285055242
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 66 | 20526 | 1318 (1)| 00:00:16 |
|* 1 | TABLE ACCESS FULL| AA | 66 | 20526 | 1318 (1)| 00:00:16 |
--------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("BILLING_DATE_TIME"=TO_DATE('2007-01-01 00:00:00',
'yyyy-mm-dd hh24:mi:ss'))
Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
5 recursive calls
0 db block gets
5938 consistent gets
5848 physical reads
0 redo size
2163 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 hash where billing_date_time=to_date('2007-01-01','yyyy=mm=dd');
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 1198858656
--------------------------------------------------------------------------------
--------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------
--------------
| 0 | SELECT STATEMENT | | 17 | 5287 | 333 (1)| 00:00:04 | | |
| 1 | PARTITION HASH SINGLE| | 17 | 5287 | 333 (1)| 00:00:04 | 1 | 1 |
|* 2 | TABLE ACCESS FULL | HASH | 17 | 5287 | 333 (1)| 00:00:04 | 1 | 1 |
--------------------------------------------------------------------------------
--------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("BILLING_DATE_TIME"=TO_DATE('2007-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
Note
-----
- dynamic sampling used for this statement
统计信息
----------------------------------------------------------
5 recursive calls
0 db block gets
1573 consistent gets
1491 physical reads
0 redo size
2163 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 range where billing_date_time=to_date('2007-01-01','yyyy=mm=dd');
未选定行
执行计划
----------------------------------------------------------
Plan hash value: 955737907
--------------------------------------------------------------------------------
----------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
--------------------------------------------------------------------------------
----------------
| 0 | SELECT STATEMENT | | 14 | 4354 | 278 (1)| 00:00:04 | | |
| 1 | PARTITION RANGE SINGLE| | 14 | 4354 | 278 (1)| 00:00:04 | 3 | 3 |
|* 2 | TABLE ACCESS FULL | RANGE | 14 | 4354 | 278 (1)| 00:00:04 | 3 | 3 |
--------------------------------------------------------------------------------
----------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("BILLING_DATE_TIME"=TO_DATE('2007-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
Note