connor mcdonald partitioning
DESCRIPTION
A look at the partitioning facilities all the way up 11gTRANSCRIPT
![Page 1: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/1.jpg)
NOTE
itty bitty fonts in this
presentation
SQL> exec sample_font
Can you read this ?
1
![Page 2: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/2.jpg)
Connor McDonald
OracleDBA
co
.uk
2
![Page 3: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/3.jpg)
3
![Page 4: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/4.jpg)
bio slide
4
![Page 5: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/5.jpg)
Connor McDonald
![Page 6: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/6.jpg)
6
![Page 7: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/7.jpg)
why ?
7
...now
![Page 8: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/8.jpg)
version 8.0
8
![Page 9: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/9.jpg)
9
![Page 10: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/10.jpg)
10
![Page 11: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/11.jpg)
a personal history
11
![Page 12: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/12.jpg)
80's
12
![Page 13: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/13.jpg)
13
![Page 14: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/14.jpg)
14
![Page 15: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/15.jpg)
Walker Interactive
15
![Page 16: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/16.jpg)
16
Jeff Walker...
![Page 17: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/17.jpg)
20G
17
![Page 18: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/18.jpg)
![Page 19: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/19.jpg)
$200
per gigabyte
per month
19
![Page 20: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/20.jpg)
Storage
is
expensive
20
![Page 21: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/21.jpg)
21
Archive
![Page 22: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/22.jpg)
22
![Page 23: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/23.jpg)
90's
23
![Page 24: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/24.jpg)
24
![Page 25: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/25.jpg)
JBOD
25
![Page 26: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/26.jpg)
26
Storage
is
cheap !
![Page 27: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/27.jpg)
27
Archive
![Page 28: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/28.jpg)
28
Archive
![Page 29: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/29.jpg)
1992 1996 1999
![Page 30: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/30.jpg)
30
![Page 31: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/31.jpg)
00's
31
![Page 32: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/32.jpg)
disk is even cheaper....
32
![Page 33: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/33.jpg)
33
![Page 34: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/34.jpg)
....but
34
![Page 35: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/35.jpg)
![Page 36: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/36.jpg)
36
keep everything !
![Page 37: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/37.jpg)
37
JBOD
![Page 38: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/38.jpg)
38
![Page 39: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/39.jpg)
39
HBA
Infiniband
Filer
Cache
Fibre Channel
etc
![Page 40: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/40.jpg)
40
Storage
is
cheap !
![Page 41: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/41.jpg)
41
Storage
is
cheap !
Storage
is
expensive
![Page 42: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/42.jpg)
42
CEO
![Page 43: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/43.jpg)
brings us to today...
43
![Page 44: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/44.jpg)
44
ILM
![Page 45: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/45.jpg)
45
Lifecycle
Information
Management
![Page 46: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/46.jpg)
46
keep everything .... cheaply
![Page 47: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/47.jpg)
47
put the new stuff on good storage
put the old stuff on crappy storage
keep everything .... cheaply
![Page 48: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/48.jpg)
48
split stuff up
![Page 49: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/49.jpg)
49
![Page 50: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/50.jpg)
50
basics
![Page 51: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/51.jpg)
51
range partitioning
since 8.0
![Page 52: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/52.jpg)
52
2009 2010 2011 2012
SALES
![Page 53: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/53.jpg)
53
provocative statement
![Page 54: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/54.jpg)
54
"all applications are (time)windows on data"
http://thehelsinkideclaration.blogspot.com/
![Page 55: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/55.jpg)
55
corollary:
everyone can benefit
from range partitions
![Page 56: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/56.jpg)
56
time the most common
![Page 57: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/57.jpg)
57
SQL> create table DEMO
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 (
9 PARTITION p01 VALUES LESS THAN
10 (TIMESTAMP' 2010-01-01 00:00:00'),
11 PARTITION p02 VALUES LESS THAN
12 (TIMESTAMP' 2010-02-01 00:00:00'),
13 PARTITION p03 VALUES LESS THAN
14 (TIMESTAMP' 2010-03-01 00:00:00'),
...
...
25 PARTITION p13 VALUES LESS THAN
26 (TIMESTAMP' 2011-01-01 00:00:00')
27 );
Table created.
![Page 58: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/58.jpg)
58
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from USER_TAB_PARTITIONS
5 where table_name = 'DEMO';
PNAME POS HIGH_VALUE
----- ---------- -------------------------------
P01 1 TIMESTAMP' 2010-01-01 00:00:00'
P02 2 TIMESTAMP' 2010-02-01 00:00:00'
P03 3 TIMESTAMP' 2010-03-01 00:00:00'
P04 4 TIMESTAMP' 2010-04-01 00:00:00'
P05 5 TIMESTAMP' 2010-05-01 00:00:00'
P06 6 TIMESTAMP' 2010-06-01 00:00:00'
P07 7 TIMESTAMP' 2010-07-01 00:00:00'
P08 8 TIMESTAMP' 2010-08-01 00:00:00'
P09 9 TIMESTAMP' 2010-09-01 00:00:00'
P10 10 TIMESTAMP' 2010-10-01 00:00:00'
P11 11 TIMESTAMP' 2010-11-01 00:00:00'
P12 12 TIMESTAMP' 2010-12-01 00:00:00'
P13 13 TIMESTAMP' 2011-01-01 00:00:00'
![Page 59: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/59.jpg)
range partition boundaries
59
![Page 60: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/60.jpg)
60
split by upper bound
![Page 61: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/61.jpg)
61
PARTITION p01 VALUES LESS THAN
(TIMESTAMP' 2010-01-01 00:00:00'),
PARTITION p02 VALUES LESS THAN
(TIMESTAMP' 2010-02-01 00:00:00'),
January not February
P02 >= 2010-01-01
P02 < 2010-02-01
![Page 62: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/62.jpg)
62
possible benefits
![Page 63: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/63.jpg)
63
performance
![Page 64: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/64.jpg)
64
partition pruning
![Page 65: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/65.jpg)
65
SQL> set autotrace traceonly explain
SQL> select * from DEMO
2 where TSTAMP = to_date('11-JUN-2010');
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE SINGLE| | 1 | 7 | 7 |
|* 2 | TABLE ACCESS FULL | DEMO | 1 | 7 | 7 |
---------------------------------------------------------------
![Page 66: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/66.jpg)
66
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from user_tab_partitions
5 where table_name = 'DEMO';
PNAME POS HIGH_VALUE
----- ---------- -------------------------------
P01 1 TIMESTAMP' 2010-01-01 00:00:00'
P02 2 TIMESTAMP' 2010-02-01 00:00:00'
P03 3 TIMESTAMP' 2010-03-01 00:00:00'
P04 4 TIMESTAMP' 2010-04-01 00:00:00'
P05 5 TIMESTAMP' 2010-05-01 00:00:00'
P06 6 TIMESTAMP' 2010-06-01 00:00:00'
P07 7 TIMESTAMP' 2010-07-01 00:00:00'
P08 8 TIMESTAMP' 2010-08-01 00:00:00'
P09 9 TIMESTAMP' 2010-09-01 00:00:00'
P10 10 TIMESTAMP' 2010-10-01 00:00:00'
P11 11 TIMESTAMP' 2010-11-01 00:00:00'
P12 12 TIMESTAMP' 2010-12-01 00:00:00'
P13 13 TIMESTAMP' 2011-01-01 00:00:00'
![Page 67: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/67.jpg)
67
more later...
![Page 68: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/68.jpg)
68
dbms_xplan
![Page 69: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/69.jpg)
69
SQL> explain plan for select ....
SQL> select *
2 from table(dbms_xplan.display)
![Page 70: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/70.jpg)
70
SQL> select *
2 from table(
3 dbms_xplan.display(
4 format=>'PARTITION -COST -BYTES'));
![Page 71: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/71.jpg)
71
SQL> select *
2 from table(dbms_xplan.display_awr(...))
![Page 72: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/72.jpg)
72
SQL> select ...
SQL> select *
2 from table(dbms_xplan.display_cursor)
![Page 73: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/73.jpg)
73
SQL> select *
2 from table(dbms_xplan.display_plan_baseline)
![Page 74: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/74.jpg)
74
back to range partitioning
![Page 75: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/75.jpg)
75
maintenance
add / drop
move
rebuild
backup / read-only
compress
cache control
![Page 76: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/76.jpg)
76
availability
recovery
partition loss
a little dubious....
![Page 77: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/77.jpg)
77
multi-column range
![Page 78: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/78.jpg)
78
SQL> create table SALES_DATA
2 ( yyyy number(4) not null,
3 mm number(2) not null,
4 sales_id varchar2(10) not null,
5 amount number(10)
6 )
7 PARTITION BY RANGE (yyyy, mm)
8 (
9 PARTITION p01 VALUES LESS THAN (2010,02),
10 PARTITION p02 VALUES LESS THAN (2010,03),
11 PARTITION p03 VALUES LESS THAN (2010,04)
...
...
22 )
23 /
Table created.
![Page 79: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/79.jpg)
79
tiebreaker
![Page 80: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/80.jpg)
80
not multi dimension
![Page 81: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/81.jpg)
81
SQL> create table MOBILE_PHONE
2 ( start_day date not null,
3 end_day date not null,
4 account_id varchar2(10) not null,
5 calls number(10)
6 )
7 PARTITION BY RANGE (start_day, end_day)
8 (
9 PARTITION p01 VALUES LESS THAN
10 ('01-FEB-2010','01-FEB-2010'),
11 PARTITION p02 VALUES LESS THAN
12 ('01-MAR-2010','01-MAR-2010'),
13 PARTITION p03 VALUES LESS THAN
14 ('01-APR-2010','01-APR-2010')
15 )
16 /
Table created.
![Page 82: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/82.jpg)
82
SQL> select sum(calls)
2 from MOBILE_PHONE
3 where START_DAY= '12-FEB-2010';
----------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | | |
| 2 | PARTITION RANGE SINGLE| | 3 | 3 |
|* 3 | TABLE ACCESS FULL | MOBILE_PHONE | 3 | 3 |
----------------------------------------------------------------
![Page 83: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/83.jpg)
83
SQL> select sum(calls)
2 from MOBILE_PHONE
3 where END_DAY= '12-FEB-2010';
----------------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | | |
| 2 | PARTITION RANGE ALL | | 1 | 3 |
|* 3 | TABLE ACCESS FULL | MOBILE_PHONE | 1 | 3 |
----------------------------------------------------------------------
![Page 84: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/84.jpg)
84
9 PARTITION p01 VALUES LESS THAN
10 ('01-FEB-2010','01-FEB-2010'),
11 PARTITION p02 VALUES LESS THAN
12 ('01-MAR-2010','01-MAR-2010'),
13 PARTITION p03 VALUES LESS THAN
14 ('01-APR-2010','01-APR-2010')
SQL> insert into MOBILE_PHONE
2 values ('07-FEB-2010','12-FEB-2010');
SQL> insert into MOBILE_PHONE
2 values ('23-JAN-2010','12-FEB-2010');
SQL> insert into MOBILE_PHONE
2 values ('17-MAR-2010','12-FEB-2010');
![Page 85: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/85.jpg)
85
better in 11g
![Page 86: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/86.jpg)
86
SQL> select sum(calls)
2 from MOBILE_PHONE
3 where END_DAY= '12-FEB-2010';
----------------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | | |
| 2 | PARTITION RANGE MULTI-COLUMN| |KEY(MC)|KEY(MC)|
|* 3 | TABLE ACCESS FULL | MOBILE_PHONE |KEY(MC)|KEY(MC)|
----------------------------------------------------------------------
![Page 87: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/87.jpg)
87
hash partitioning
since 8.1
![Page 88: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/88.jpg)
88
big stuff is a pain
![Page 89: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/89.jpg)
89
"metapoor"
![Page 90: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/90.jpg)
![Page 91: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/91.jpg)
![Page 92: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/92.jpg)
92
possible benefits
![Page 93: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/93.jpg)
93
manageability
![Page 94: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/94.jpg)
94
![Page 95: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/95.jpg)
95
move
backup
etc
![Page 96: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/96.jpg)
96
insertion
performance
![Page 97: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/97.jpg)
97
"buffer busy waits"
![Page 98: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/98.jpg)
98
"enq: HW - contention"
![Page 99: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/99.jpg)
99
"read by other session"
![Page 100: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/100.jpg)
100
![Page 101: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/101.jpg)
101
less relevant nowadays
for tables
![Page 102: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/102.jpg)
102
ASSM
![Page 103: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/103.jpg)
103
automatic
segment
space
management
![Page 104: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/104.jpg)
104
SQL> CREATE TABLESPACE DEMO
2 DATAFILE '...' SIZE 20G
3 EXTENT MANAGEMENT LOCAL
4 SEGMENT SPACE MANAGEMENT AUTO;
![Page 105: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/105.jpg)
105
![Page 106: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/106.jpg)
106
...but still very important
see later
![Page 107: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/107.jpg)
107
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 8
5 /
Table created.
![Page 108: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/108.jpg)
108
even spread of values
![Page 109: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/109.jpg)
109
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 8
5 /
Table created.
SQL> insert into T
2 select level
3 from dual connect by level <= 100000
4 /
100000 rows created.
1,2,3,4 .... 100000
![Page 110: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/110.jpg)
110
SQL> select DBMS_ROWID.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by DBMS_ROWID.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
72166 12381
72167 12628
72161 12603
72162 12574
72163 12581
72168 12382
72164 12508
72165 12342
![Page 111: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/111.jpg)
111
predicting hash target
![Page 112: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/112.jpg)
remember these
112
SQL> select dbms_rowid.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by dbms_rowid.ROWID_OBJECT(rowid)
5 order by 2;
PTN COUNT(*)
---------- ----------
73535 12342
73536 12381
73538 12382
73534 12508
73532 12574
73533 12581
73531 12603
73537 12628
SQL> select ora_hash(x,7), count(*)
2 from t
3 group by ora_hash(x,7)
4 order by 2;
ORA_HASH(X,7) COUNT(*)
------------- ----------
4 12342
5 12381
7 12382
3 12508
1 12574
2 12581
0 12603
6 12628
![Page 113: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/113.jpg)
113
the power of 2 rule
![Page 114: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/114.jpg)
114
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 4 | 8 | 16 | 32 ...
5 /
Table created.
![Page 115: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/115.jpg)
115
SQL> select DBMS_ROWID.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by DBMS_ROWID.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
72166 12381
72167 12628
72161 12603
72162 12574
72163 12581
72168 12382
72164 12508
72165 12342
![Page 116: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/116.jpg)
116
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 5
5 /
Table created.
SQL> insert into T
2 select level
3 from dual connect by level <= 100000
4 /
100000 rows created.
![Page 117: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/117.jpg)
117
SQL> select DBMS_ROWID.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by DBMS_ROWID.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
72174 12342
72172 25209
72171 24955
72173 24890
72170 12603
![Page 118: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/118.jpg)
118
why ?
![Page 119: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/119.jpg)
119
deliberately
for maintenance...
![Page 120: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/120.jpg)
120
Task:
from 5 to 8 partitions
![Page 121: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/121.jpg)
121
"classical" redistribution
![Page 122: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/122.jpg)
122
"every" row moves
![Page 123: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/123.jpg)
123
SQL> select count(*)
2 from T
3 where ora_hash(x,4) != ora_hash(x,7);
COUNT(*)
----------
87564
![Page 124: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/124.jpg)
124
"smart" redistribution
![Page 125: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/125.jpg)
125
SQL> select DBMS_ROWID.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by DBMS_ROWID.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
72174 12342
72172 25209
72171 24955
72173 24890
72170 12603
5 rows selected.
pick one
![Page 126: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/126.jpg)
126
SQL> alter table T add partition;
Table altered.
SQL> select dbms_rowid.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by dbms_rowid.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
73515 25209
73516 24890
73517 12342
73519 12381
73518 12574
73513 12603
![Page 127: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/127.jpg)
127
SQL> alter table T add partition;
Table altered.
SQL> select dbms_rowid.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by dbms_rowid.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
73516 24890
73517 12342
73519 12381
73518 12574
73521 12628
73520 12581
73513 12603
![Page 128: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/128.jpg)
128
SQL> alter table T add partition;
Table altered.
SQL> select dbms_rowid.ROWID_OBJECT(rowid) ptn,
2 count(*)
3 from T
4 group by dbms_rowid.ROWID_OBJECT(rowid);
PTN COUNT(*)
---------- ----------
73517 12342
73523 12382
73522 12508
73519 12381
73518 12574
73521 12628
73520 12581
73513 12603
![Page 129: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/129.jpg)
129
only 1 partition "effort"
![Page 130: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/130.jpg)
130
same for coalesce partition
![Page 131: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/131.jpg)
131
handling a small number of values
![Page 132: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/132.jpg)
132
range fiddly....
SQL> create table ...
...
20 values less than ('WB'),
21 values less than ('QLE'),
22 values less than ('SB'),
23 values less than ('VID'),
![Page 133: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/133.jpg)
133
hash ... poor distribution
SQL> select state, ora_hash(state,7) hash
2 from AUST;
STATE HASH
----- ----
WA 2
SA 5
NSW 3
VIC 5
![Page 134: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/134.jpg)
134
list
version 9
![Page 135: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/135.jpg)
135
SQL> create table SALES_DATA
2 ( sales_id varchar2(10) not null,
3 location varchar2(3) not null,
4 amount number(10)
5 )
6 PARTITION BY LIST (location)
7 (
8 PARTITION NSW VALUES ('NSW'),
9 PARTITION WA VALUES ('WA'),
10 PARTITION QLD VALUES ('QLD'),
11 PARTITION SA VALUES ('SA'),
12 PARTITION VIC VALUES ('VIC'),
13 PARTITION TERR VALUES ('ACT','NT'),
14 PARTITION DREGS VALUES (DEFAULT)
15 )
18 /
Table created.
![Page 136: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/136.jpg)
136
think carefully on DEFAULT
add versus split
![Page 137: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/137.jpg)
137
sometimes one level is not enough
![Page 138: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/138.jpg)
138
![Page 139: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/139.jpg)
139
![Page 140: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/140.jpg)
140
ranges unevenly distributed
![Page 141: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/141.jpg)
141
deletion of older data
20092010
2011 2012
![Page 142: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/142.jpg)
142
composite partitions
![Page 143: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/143.jpg)
143
composite (range + hash)
since 8.1
![Page 144: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/144.jpg)
144
SQL> create table COMP
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 SUBPARTITION BY LIST (deptno)
9 (
10 PARTITION p01 VALUES LESS THAN
11 (TIMESTAMP' 2010-01-01 00:00:00')
12 (SUBPARTITION p01_d1 VALUES (1),
13 SUBPARTITION p01_d2 VALUES (2),
14 SUBPARTITION p01_d3 VALUES (3),
15 SUBPARTITION p01_d4 VALUES (4)),
16 PARTITION p02 VALUES LESS THAN
17 (TIMESTAMP' 2010-02-01 00:00:00')
18 (SUBPARTITION p02_d1 VALUES (1),
19 SUBPARTITION p02_d2 VALUES (2),
20 SUBPARTITION p02_d3 VALUES (3),
21 SUBPARTITION p02_d4 VALUES (4)),
.....
![Page 145: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/145.jpg)
145
30 PARTITION p11 VALUES LESS THAN
31 (TIMESTAMP' 2010-11-01 00:00:00')
32 (SUBPARTITION p01_d1 VALUES (1,2),
33 SUBPARTITION p01_d2 VALUES (3,4),
34 PARTITION p12 VALUES LESS THAN
35 (TIMESTAMP' 2010-12-01 00:00:00')
36 PARTITION p13 VALUES LESS THAN
37 (TIMESTAMP' 2011-01-01 00:00:00')
.....
recall: coalesce partition
![Page 146: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/146.jpg)
146
long DDL .....
![Page 147: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/147.jpg)
147
subpartition templates
![Page 148: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/148.jpg)
148
SQL> create table COMP
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 SUBPARTITION BY LIST (deptno)
9 SUBPARTITION TEMPLATE
10 (SUBPARTITION d1 VALUES (1),
11 SUBPARTITION d2 VALUES (2),
12 SUBPARTITION d3 VALUES (3),
13 SUBPARTITION d4 VALUES (4))
14 (
15 PARTITION p01 VALUES LESS THAN
16 (TIMESTAMP' 2010-01-01 00:00:00'),
17 PARTITION p02 VALUES LESS THAN
18 (TIMESTAMP' 2010-02-01 00:00:00'),
19 ....
implicit
subpar's
![Page 149: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/149.jpg)
149
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from USER_TAB_PARTITIONS
5 where table_name = 'COMP';
PNAME POS HIGH_VALUE
---------- ---------- --------------------------------
P01 1 TIMESTAMP' 2010-01-01 00:00:00'
P02 2 TIMESTAMP' 2010-02-01 00:00:00'
P03 3 TIMESTAMP' 2010-03-01 00:00:00'
P04 4 TIMESTAMP' 2010-04-01 00:00:00'
P05 5 TIMESTAMP' 2010-05-01 00:00:00'
P06 6 TIMESTAMP' 2010-06-01 00:00:00'
P07 7 TIMESTAMP' 2010-07-01 00:00:00'
P08 8 TIMESTAMP' 2010-08-01 00:00:00'
...
![Page 150: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/150.jpg)
150
SQL> select subpartition_name pname,
2 subpartition_position pos,
3 high_value
4 from USER_TAB_SUBPARTITIONS
5 where table_name = 'COMP'
6 order by 1,2;
PNAME POS HIGH_VALUE
---------- ---------- ----------------------
P01_D1 1 '1'
P01_D2 2 '2'
P01_D3 3 '3'
P01_D4 4 '4'
P02_D1 1 '1'
P02_D2 2 '2'
P02_D3 3 '3'
P02_D4 4 '4'
P03_D1 1 '1'
...
...
auto named for
subpar templates
![Page 151: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/151.jpg)
151
partitions
logical or physical
![Page 152: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/152.jpg)
152
composite (range + list)
since 9
![Page 153: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/153.jpg)
153
composite (anything + anything)
since 11
![Page 154: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/154.jpg)
154
interval partitioning
11g
![Page 155: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/155.jpg)
155
the problem with ranges....
![Page 156: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/156.jpg)
156
... they are a range
![Page 157: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/157.jpg)
157
require maintenance
![Page 158: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/158.jpg)
158
SQL> insert into DEMO
2 values ( to_date('01-JAN-2014'), .... );
insert into DEMO
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
25 PARTITION p13 VALUES LESS THAN
26 (TIMESTAMP' 2011-01-01 00:00:00')
27 );
![Page 159: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/159.jpg)
159
insurance policy
![Page 160: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/160.jpg)
160
SQL> insert into DEMO
2 values ( to_date('01-JAN-2014'), .... );
1 row created.
25 PARTITION p13 VALUES LESS THAN
26 (TIMESTAMP' 2011-01-01 00:00:00')
26 PARTITION pmax VALUES LESS THAN
27 (MAXVALUE)
28 );
magic value
![Page 161: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/161.jpg)
161
why MAXVALUE might hurt
(part 1)
![Page 162: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/162.jpg)
162
split not add
![Page 163: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/163.jpg)
163
SQL> alter table DEMO split partition PMAX
2 at ( TIMESTAMP' 2012-02-01 00:00:00')
3 into ( partition p14, partition pmax )
4 /
Table altered.
![Page 164: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/164.jpg)
164
hoping for empty partition
![Page 165: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/165.jpg)
165
"fast split" partition
![Page 166: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/166.jpg)
166
index hassles
see later...
![Page 167: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/167.jpg)
167
"solved" in 11g
![Page 168: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/168.jpg)
168
![Page 169: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/169.jpg)
169
interval partitioning
![Page 170: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/170.jpg)
170
SQL> create table DEMO
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 INTERVAL( NUMTOYMINTERVAL(1,'MONTH'))
9 (
10 PARTITION P00 VALUES LESS THAN
11 (TIMESTAMP' 2010-01-01 00:00:00')
11 );
Table created.
![Page 171: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/171.jpg)
171
partitions created as required
![Page 172: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/172.jpg)
172
SQL> select PARTITION_NAME, HIGH_VALUE
2 from user_tab_partitions
3 where table_name = 'DEMO';
PARTITION_NAME HIGH_VALUE
------------------------- --------------------------------
P00 TIMESTAMP' 2010-01-01 00:00:00'
SQL> insert into DEMO
2 values ( to_date('12-DEC-2011'),....);
1 row created.
SQL> select PARTITION_NAME, HIGH_VALUE
2 from user_tab_partitions
3 where table_name = 'DEMO';
PARTITION_NAME HIGH_VALUE
------------------------- --------------------------------
P00 TIMESTAMP' 2010-01-01 00:00:00'
SYS_P362 TIMESTAMP' 2012-01-01 00:00:00'
![Page 173: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/173.jpg)
173
gaps allowed
![Page 174: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/174.jpg)
range partition boundaries
174
Length Length Length
![Page 175: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/175.jpg)
175
partition name control lost
can rename....
![Page 176: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/176.jpg)
176
convert range to interval
![Page 177: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/177.jpg)
177
SQL> alter table DEMO
2 SET INTERVAL ( NUMTOYMINTERVAL(1,'MONTH') );
Table altered.
original range version
![Page 178: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/178.jpg)
178
SQL> insert into DEMO
2 values ( to_date('01-JAN-2017'),....);
1 row created.
![Page 179: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/179.jpg)
179
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from user_tab_partitions
5 where table_name = 'DEMO';
PNAME POS HIGH_VALUE
------------ ---------- --------------------------------
P01 1 TIMESTAMP' 2010-01-01 00:00:00'
P02 2 TIMESTAMP' 2010-02-01 00:00:00'
P03 3 TIMESTAMP' 2010-03-01 00:00:00'
P04 4 TIMESTAMP' 2010-04-01 00:00:00'
...
P10 10 TIMESTAMP' 2010-10-01 00:00:00'
P11 11 TIMESTAMP' 2010-11-01 00:00:00'
P12 12 TIMESTAMP' 2010-12-01 00:00:00'
P13 13 TIMESTAMP' 2011-01-01 00:00:00'
SYS_P1091 14 TIMESTAMP' 2017-02-01 00:00:00'
![Page 180: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/180.jpg)
180
but be careful ...
![Page 181: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/181.jpg)
181
hybrid
range range range interval
![Page 182: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/182.jpg)
182
is it range or interval ?
![Page 183: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/183.jpg)
183
SQL> desc DBA_TAB_PARTITIONS
Name Null? Type
----------------------- -------- ----------------
TABLE_OWNER VARCHAR2(30)
TABLE_NAME VARCHAR2(30)
COMPOSITE VARCHAR2(3)
PARTITION_NAME VARCHAR2(30)
SUBPARTITION_COUNT NUMBER
HIGH_VALUE LONG
HIGH_VALUE_LENGTH NUMBER
PARTITION_POSITION NUMBER
TABLESPACE_NAME VARCHAR2(30)
...
LOGGING VARCHAR2(7)
COMPRESSION VARCHAR2(8)
COMPRESS_FOR VARCHAR2(18)
NUM_ROWS NUMBER
BUFFER_POOL VARCHAR2(7)
GLOBAL_STATS VARCHAR2(3)
USER_STATS VARCHAR2(3)
?
![Page 184: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/184.jpg)
184
SQL> select o.subname,
2 decode(bitand(tp.flags,32768),
3 32768,'YES','NO') interval
4 from SYS.TABPART$ tp, SYS.OBJ$ o
6 where tp.obj# = o.obj#
6 and o.name = 'DEMO';
SUBNAME INT
------------------------------ ---
P01 NO
P02 NO
P03 NO
P04 NO
P05 NO
...
P11 NO
P12 NO
P13 NO
SYS_P1091 YES
14 rows selected.
![Page 185: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/185.jpg)
185
fixed in 11.2
![Page 186: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/186.jpg)
186
high range value gets "stuck"
![Page 187: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/187.jpg)
187
SQL> insert into DEMO
2 values ( to_date('01-JAN-2017'),...);
1 row created.
SQL> insert into DEMO
2 values ( to_date('01-JAN-2016'),...);
1 row created.
![Page 188: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/188.jpg)
188
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from user_tab_partitions
5 where table_name = 'DEMO';
PNAME POS HIGH_VALUE
------------ ---------- -------------------------------
P01 1 TIMESTAMP' 2010-01-01 00:00:00'
P02 2 TIMESTAMP' 2010-02-01 00:00:00'
P03 3 TIMESTAMP' 2010-03-01 00:00:00'
P04 4 TIMESTAMP' 2010-04-01 00:00:00'
...
P13 13 TIMESTAMP' 2011-01-01 00:00:00'
SYS_P1112 14 TIMESTAMP' 2016-02-01 00:00:00'
SYS_P1111 15 TIMESTAMP' 2017-02-01 00:00:00'
![Page 189: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/189.jpg)
189
SQL> alter table DEMO drop partition P01;
Table altered.
SQL> alter table DEMO drop partition P02;
Table altered.
SQL> alter table DEMO drop partition P13;
alter table DEMO drop partition P13
*
ERROR at line 1:
ORA-14758: Last partition in the range
section cannot be dropped
![Page 190: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/190.jpg)
190
Length Length Length
![Page 191: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/191.jpg)
191
workarounds (maybe) unpleasant....
![Page 192: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/192.jpg)
192
SQL> alter table DEMO set interval ( );
Table altered.
SQL> alter table DEMO
2 set interval (NUMTOYMINTERVAL(1,'MONTH'));
Table altered.
![Page 193: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/193.jpg)
193
SQL> alter table DEMO merge partitions
2 for (TIMESTAMP' 2010-12-30 00:00:00'),
3 for (TIMESTAMP' 2016-01-10 00:00:00');
Table altered.
![Page 194: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/194.jpg)
194
11.2
![Page 195: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/195.jpg)
195
SQL> alter table DEMO
2 set interval (NUMTOYMINTERVAL(1,'MONTH'));
Table altered.
![Page 196: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/196.jpg)
196
why MAXVALUE might hurt
(part 2)
![Page 197: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/197.jpg)
197
SQL> create table DEMO
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 (
9 PARTITION p01 VALUES LESS THAN
10 (TIMESTAMP' 2010-01-01 00:00:00'),
...
25 partition PMAX values less than (MAXVALUE)
26 )
27 /
Table created.
![Page 198: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/198.jpg)
198
SQL> alter table DEMO
2 set interval ( NUMTOYMINTERVAL(1,'MONTH') );
*
ERROR at line 1:
ORA-14759: SET INTERVAL is not legal on this table.
![Page 199: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/199.jpg)
199
explain plan anomaly
![Page 200: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/200.jpg)
200
INTERVAL = "1 million partitions"
![Page 201: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/201.jpg)
201
SQL> create table DEMO
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 INTERVAL( NUMTOYMINTERVAL(1,'MONTH'))
9 (
10 PARTITION P00 VALUES LESS THAN
11 (TIMESTAMP' 2010-01-01 00:00:00')
12 );
Table created.
![Page 202: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/202.jpg)
202
SQL> select * from DEMO;
------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE ALL| | 1 | 1 |1048575|
| 2 | TABLE ACCESS FULL | DEMO | 1 | 1 |1048575|
------------------------------------------------------------
![Page 203: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/203.jpg)
203
partitioned tables ...
the bigger picture
![Page 204: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/204.jpg)
204
2009 2010 2011 2012
SALES
SALES_ITEMS
SQL> desc SALES_ITEMS
Name Null? Type
-------------------- -------- -----------
SALE_ID NOT NULL NUMBER(12)
ITEM_ID NOT NULL NUMBER(12)
...
SQL> desc SALES
Name Null? Type
-------------------- -------- --------------
SALE_DATE NOT NULL DATE
...
![Page 205: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/205.jpg)
205
reference partitions
11g
![Page 206: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/206.jpg)
206
SQL> create table PARENT
2 ( d date not null,
3 p number(10) not null,
4 pad char(10)
5 )
6 PARTITION BY RANGE (d)
7 (
8 PARTITION p1 VALUES LESS THAN ( to_date('01-JAN-2010')),
9 PARTITION p2 VALUES LESS THAN ( to_date('01-FEB-2010')),
10 PARTITION p3 VALUES LESS THAN ( to_date('01-MAR-2010')),
11 PARTITION p4 VALUES LESS THAN ( to_date('01-APR-2010')),
12 PARTITION p5 VALUES LESS THAN ( to_date('01-MAY-2010')),
13 PARTITION p6 VALUES LESS THAN ( to_date('01-JUN-2010')),
14 PARTITION p7 VALUES LESS THAN ( to_date('01-JUL-2010')),
15 PARTITION p8 VALUES LESS THAN ( to_date('01-AUG-2010')),
16 PARTITION p9 VALUES LESS THAN ( to_date('01-SEP-2010'))
17 );
Table created.
SQL> alter table PARENT add primary key ( p );
Table altered.
![Page 207: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/207.jpg)
207
SQL> create table CHILD
2 ( p number(10) not null,
3 c number(10) not null,
4 constraint CHILD_FK foreign key ( p )
5 references PARENT (p)
6 on delete cascade
7 )
8 PARTITION BY REFERENCE (CHILD_FK)
9 /
Table created.
![Page 208: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/208.jpg)
208
SQL> insert into PARENT
2 select sysdate+rownum, rownum, rownum
3 from dual connect by level <= 100
4 /
100 rows created.
SQL> insert into CHILD
2 select rownum, rownum
3 from dual connect by level <= 100
4 /
100 rows created.
![Page 209: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/209.jpg)
209
SQL> exec dbms_stats.gather_table_stats(user,'CHILD');
PL/SQL procedure successfully completed.
SQL> select partition_name, num_rows
2 from USER_TAB_PARTITIONS
3 where table_name = 'CHILD';
PARTITION_NAME NUM_ROWS
------------------------------ ----------
P1 0
P2 0
P3 0
P4 0
P5 9
P6 31
P7 30
P8 30
P9 0
![Page 210: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/210.jpg)
210
seems good .... but
![Page 211: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/211.jpg)
211
SQL> create table CHILD
2 ( p number(10),
3 c number(10),
4 constraint CHILD_FK foreign key ( p )
5 references PARENT (p)
6 )
7 PARTITION BY REFERENCE (CHILD_FK)
8 /
PARTITION BY REFERENCE (CHILD_FK)
*
ERROR at line 7:
ORA-14652: reference partitioning foreign key is not supported
null
![Page 212: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/212.jpg)
212
SQL> create table PARENT
2 ( d date not null,
3 p number(10) not null,
4 pad char(10)
5 )
6 PARTITION BY RANGE (d)
7 INTERVAL( NUMTOYMINTERVAL(1,'MONTH'))
8 ( PARTITION VALUES LESS THAN ( to_date('01-JAN-2010')) );
Table created.
SQL> create table CHILD
2 ( p number(10) not null,
3 c number(10) not null,
4 constraint CHILD_FK foreign key ( p )
5 references PARENT (p)
6 on delete cascade
7 )
8 PARTITION BY REFERENCE (CHILD_FK);
create table CHILD
*
ERROR at line 1:
ORA-14659: Partitioning method of the parent table is not supported
![Page 213: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/213.jpg)
213
but the following "works"....
![Page 214: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/214.jpg)
214
SQL> alter table PARENT
2 set INTERVAL( NUMTOYMINTERVAL(1,'MONTH'));
Table altered.
SQL> insert into PARENT values (sysdate+1000,-1,'x');
1 row created.
SQL> select partition_name
2 from user_tab_partitions
3 where table_name = 'PARENT';
PARTITION_NAME
------------------------------
SYS_P1196
P1
P2
P3
...
pk=-1
![Page 215: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/215.jpg)
215
SQL> insert into CHILD values (-1,0);
insert into CHILD values (-1,0)
*
ERROR at line 1:
ORA-14401: inserted partition key is outside
specified partition
![Page 216: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/216.jpg)
216
dropping requires order
![Page 217: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/217.jpg)
217
SQL> drop table PARENT;
drop table PARENT
*
ERROR at line 1:
ORA-02449: unique/primary keys in table referenced by
foreign keys
SQL> drop table PARENT cascade constraints;
drop table PARENT cascade constraints
*
ERROR at line 1:
ORA-14656: cannot drop the parent of a reference-
partitioned table
![Page 218: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/218.jpg)
218
its a very new feature
Suboptimal Query when Gather Partition Stats on Reference Partitioned
Wrong Results In 11g On Reference Partitioned Table
ORA-7445[KKPAMDINFO] ON SELECT AGAINST A REFERENCE
PARTITIONED TABLE
Drop of reference partition not allowed (ORA-2266) with FK between siblings
UNIQUE INDEX NOT WORKING PROPERLY ON PARTITIONED BY
REFERENCE TABLE
ALLOW DROP PARTITION TO SUCCEED ON REFERENCED PARTITION
WITHOUT CORRUPTING DATA.
![Page 219: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/219.jpg)
219
Part 2
indexes on partitioned tables
![Page 220: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/220.jpg)
220
![Page 221: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/221.jpg)
221
2009 2010 2011 2012
SALES
SQL> create index SALES_IX on SALES ( CUSTOMER );
![Page 222: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/222.jpg)
222
2009 2010 2011 2012
![Page 223: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/223.jpg)
223
"global" index
![Page 224: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/224.jpg)
224
big....really big
extended rowid
![Page 225: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/225.jpg)
225
ILM issues
![Page 226: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/226.jpg)
226
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009
![Page 227: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/227.jpg)
227
SQL> create index DEMO_IX on DEMO ( empno );
Index created.
SQL> select status
2 from user_indexes
3 where index_name = 'DEMO_IX';
STATUS
--------
VALID
SQL> select * from DEMO where empno = 123;
---------------------------------------------------------------------
| Id | Operation | Name |Pstart| Pstop |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | TABLE ACCESS BY GLOBAL INDEX ROWID| DEMO |ROWID | ROWID |
|* 2 | INDEX RANGE SCAN | DEMO_IX | | |
---------------------------------------------------------------------
![Page 228: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/228.jpg)
228
SQL> alter table DEMO drop partition P06;
Table altered.
SQL> select status
2 from user_indexes
3 where index_name = 'DEMO_IX';
STATUS
--------
UNUSABLE
SQL> select * from DEMO where empno = 123;
------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 50 | | |
| 1 | PARTITION RANGE ALL| | 50 | 1 | 13 |
|* 2 | TABLE ACCESS FULL | DEMO | 50 | 1 | 13 |
------------------------------------------------------------
![Page 229: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/229.jpg)
229
SQL> select value
2 from v$parameter
3 where name = 'skip_unusable_indexes';
VALUE
------------------------------
TRUE
![Page 230: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/230.jpg)
230
keep the index valid
![Page 231: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/231.jpg)
231
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009
2 update indexes;
![Page 232: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/232.jpg)
232
large delete
redo
undo
![Page 233: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/233.jpg)
233
similar issues
merge
split
exchange
![Page 234: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/234.jpg)
234
an alternative
![Page 235: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/235.jpg)
235
"local" index
![Page 236: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/236.jpg)
236
2009 2010 2011 2012
SQL> create index SALES_IX ON SALES ( CUSTOMER )
2 LOCAL;
![Page 237: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/237.jpg)
237
smaller chunks
![Page 238: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/238.jpg)
238
smaller rowid's
![Page 239: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/239.jpg)
239
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009;
![Page 240: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/240.jpg)
240
SQL> create index DEMO_IX on DEMO ( empno ) LOCAL;
Index created.
SQL> select partition_name, status
2 from user_ind_partitions
3 where index_name = 'DEMO_IX';
PARTITION_NAME STATUS
------------------------------ -------
P01 USABLE
P02 USABLE
P03 USABLE
P04 USABLE
P05 USABLE
P06 USABLE
P07 USABLE
...
![Page 241: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/241.jpg)
241
SQL> alter table DEMO drop partition P06;
Table altered.
SQL> select partition_name, status
2 from user_ind_partitions
3 where index_name = 'DEMO_IX';
PARTITION_NAME STATUS
------------------------------ -------
P01 USABLE
P02 USABLE
P03 USABLE
P04 USABLE
P05 USABLE
P06 USABLE
P07 USABLE
...
![Page 242: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/242.jpg)
242
awesome for ILM
![Page 243: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/243.jpg)
243
handlng old data
![Page 244: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/244.jpg)
244
2009 2010 2011 2012
SQL> alter table SALES move partition SALES_2009
2 COMPRESS;
![Page 245: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/245.jpg)
245
2009 2010 2011 2012
SQL> alter table SALES move partition SALES_2009
2 TABLESPACE CRAPPY_OLD_DISK;
SQL> alter tablespace CRAPPY_OLD_DISK READ ONLY;
RMAN
![Page 246: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/246.jpg)
246
11.2 very cool
![Page 247: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/247.jpg)
247
"segment-less" segments
![Page 248: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/248.jpg)
248
2009 2010 2011 2012
SQL> alter index SALES_IX partition SALES_IX_2009
2 UNUSABLE;
![Page 249: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/249.jpg)
249
handlng new data
![Page 250: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/250.jpg)
250
2010 2011 201220132013
SQL> alter table SALES exchange
2 partition SALES_2013 with
3 table NEW_SALES;
![Page 251: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/251.jpg)
local = goodlocal = good
![Page 252: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/252.jpg)
252
global = badglobal = bad
![Page 253: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/253.jpg)
253
NO !
![Page 254: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/254.jpg)
254
different "target audience"
![Page 255: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/255.jpg)
255
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123;
123 123 123 123
SQL> create index SALES_IX on SALES ( CUSTOMER ) LOCAL;
![Page 256: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/256.jpg)
256
can be much much worse...
![Page 257: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/257.jpg)
257
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123;
WA VIC
NSW QLD
WA VIC
NSW QLD
WA VIC
NSW QLD
WA VIC
NSW QLD
![Page 258: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/258.jpg)
258
explain plan
![Page 259: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/259.jpg)
259
SQL> select * from SALES
2 where CUSTOMER= 123;
----------------------------------------------------------------------
| Id | Operation | Name |Pstart | Pstop |
----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | PARTITION RANGE ALL | | 1 | 13 |
| 2 | TABLE ACCESS BY LOCAL INDEX ROWID| SALES | 1 | 13 |
|* 3 | INDEX RANGE SCAN | SALES_IX| 1 | 13 |
----------------------------------------------------------------------
![Page 260: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/260.jpg)
260
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123;
123123123123
SQL> create index SALES_IX on SALES ( CUSTOMER ) LOCAL;
![Page 261: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/261.jpg)
261
"so global forindex lookups then"....
![Page 262: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/262.jpg)
262
NO !
![Page 263: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/263.jpg)
263
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123
4 and YEAR = 2010;
123
![Page 264: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/264.jpg)
264
careful design
![Page 265: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/265.jpg)
265
application compromises
eg unique keys
![Page 266: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/266.jpg)
266
so far ... "equipartition"
![Page 267: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/267.jpg)
267
SALES
SQL> create index SALES_IX ON SALES ( CUSTOMER )
2 global
3 partition by ....
![Page 268: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/268.jpg)
268
2009 2010 2011 2012
SQL> create index SALES_IX
2 on SALES ( location, empno )
3 global partition by range ( location )
4 ( partition p0 values less than (1),
6 partition p1 values less than (2),
...
12 partition pmax values less than (maxvalue)
13 );
Index created.
![Page 269: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/269.jpg)
269
rare ....
![Page 270: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/270.jpg)
270
...one special case
10g+
![Page 271: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/271.jpg)
271
hash partitioned index
![Page 272: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/272.jpg)
272
recall: hash partitioned tables
![Page 273: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/273.jpg)
273
concurrencyASSM
![Page 274: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/274.jpg)
274
indexes a problem
![Page 275: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/275.jpg)
275
![Page 276: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/276.jpg)
276
hash partitioned indexes
![Page 277: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/277.jpg)
277
SQL> create index SALES_PK on SALES( TXN_ID )
2 global partition by hash ( TXN_ID )
3 partitions 8
4 /
Index created.
![Page 278: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/278.jpg)
278
![Page 279: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/279.jpg)
279
only for equality
primary keys
![Page 280: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/280.jpg)
280
beware the NOSORT
![Page 281: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/281.jpg)
281
reference partitions and indexes
![Page 282: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/282.jpg)
282
2009 2010 2011 2012
2009 2010 2011 2012
SALES
SALES_ITEMS
![Page 283: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/283.jpg)
283
take care with ILM
![Page 284: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/284.jpg)
284
SQL> alter table PARENT drop partition P6;
Table altered.
SQL> select partition_name
2 from user_tab_partitions
3 where table_name = 'CHILD';
PARTITION_NAME
------------------------------
P1
P2
P3
P4
P5
P7
P8
P9
![Page 285: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/285.jpg)
285
SQL> alter table PARENT truncate partition P7;
alter table PARENT truncate partition P7
*
ERROR at line 1:
ORA-02266: unique/primary keys in table referenced by
enabled foreign keys
SQL> alter table CHILD truncate partition P7;
Table truncated.
SQL> alter table PARENT truncate partition P7;
Table truncated.
gap
![Page 286: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/286.jpg)
286
SQL> select index_name, status from user_indexes;
INDEX_NAME STATUS
------------------------------ --------
PARENT_PK UNUSABLE
CHILD_PK UNUSABLE
![Page 287: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/287.jpg)
287
exchange is difficult...
![Page 288: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/288.jpg)
288
plus more restrictions.....
![Page 289: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/289.jpg)
289
Part 3
partition queries
![Page 290: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/290.jpg)
290
partition pruning
![Page 291: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/291.jpg)
291
efficiency =
data required /
data scanned
![Page 292: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/292.jpg)
292
SQL> create table DEMO
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 (
9 PARTITION p01 VALUES LESS THAN
10 (TIMESTAMP' 2010-01-01 00:00:00'),
11 PARTITION p02 VALUES LESS THAN
12 (TIMESTAMP' 2010-02-01 00:00:00'),
13 PARTITION p03 VALUES LESS THAN
14 (TIMESTAMP' 2010-03-01 00:00:00'),
...
...
25 PARTITION p13 VALUES LESS THAN
26 (TIMESTAMP' 2011-01-01 00:00:00')
27 );
Table created.
![Page 293: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/293.jpg)
293
SQL> insert /*+ APPEND */ into DEMO
2 select trunc(sysdate,'YYYY')+rownum/( 1000000 / 360 ),
3 rownum,
4 rownum,
5 mod(rownum,1000)
6 from dual
7 connect by level <= 1000000
8 /
1000000 rows created.
360 days
![Page 294: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/294.jpg)
294
SQL> select * from DEMO
2 where TSTAMP = to_date('01-JUN-2010');
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE SINGLE| | 1 | 7 | 7 |
|* 2 | TABLE ACCESS FULL | DEMO | 1 | 7 | 7 |
---------------------------------------------------------------
![Page 295: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/295.jpg)
295
SQL> select * from DEMO
2 where TRUNC(TSTAMP) = to_date('01-JUN-2010');
------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 10000 | | |
| 1 | PARTITION RANGE ALL| | 10000 | 1 | 13 |
|* 2 | TABLE ACCESS FULL | DEMO | 10000 | 1 | 13 |
------------------------------------------------------------
![Page 296: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/296.jpg)
296
static versus dynamic
![Page 297: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/297.jpg)
297
SQL> select * from DEMO
2 where TSTAMP = :b1;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE SINGLE| | 1 | KEY | KEY |
|* 2 | TABLE ACCESS FULL | DEMO | 1 | KEY | KEY |
---------------------------------------------------------------
![Page 298: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/298.jpg)
298
lots of power
varies by version
![Page 299: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/299.jpg)
299
SQL> select * from DEMO
2 where TSTAMP between to_date('12-JAN-2010')
3 and to_date('07-FEB-2010')
4 or TSTAMP between to_date('03-JUN-2010')
5 and to_date('06-AUG-2010');
-----------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
-----------------------------------------------------------
| 0 | SELECT STATEMENT | | 240K| | |
| 1 | PARTITION RANGE OR| | 240K|KEY(OR)|KEY(OR)|
|* 2 | TABLE ACCESS FULL| DEMO | 240K|KEY(OR)|KEY(OR)|
-----------------------------------------------------------
![Page 300: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/300.jpg)
300
SQL> select * from DEMO
2 where TSTAMP in (to_date('01-JUN-2010'),
3 to_date('01-DEC-2010'));
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | | |
| 1 | PARTITION RANGE INLIST| | 2 |KEY(I) |KEY(I) |
|* 2 | TABLE ACCESS FULL | DEMO | 2 |KEY(I) |KEY(I) |
---------------------------------------------------------------
![Page 301: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/301.jpg)
301
limitations of explain plan
![Page 302: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/302.jpg)
302
SQL> select * from DEMO
2 where TSTAMP in (to_date('01-JUN-2010'),
3 to_date('01-DEC-2010'));
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | | |
| 1 | PARTITION RANGE INLIST| | 2 |KEY(I) |KEY(I) |
|* 2 | TABLE ACCESS FULL | DEMO | 2 |KEY(I) |KEY(I) |
---------------------------------------------------------------
JUN JUL AUG SEP OCT NOV DEC
![Page 303: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/303.jpg)
303
SQL> alter table DEMO move partition P08 tablespace USERS;
Table altered.
SQL> alter tablespace USERS offline;
Tablespace altered.
SQL> select count(*) from DEMO
2 where TSTAMP in (to_date('01-JUN-2010'),
3 to_date('01-DEC-2010'));
COUNT(*)
----------
1234
July
![Page 304: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/304.jpg)
304
SQL> select count(*) from DEMO
2 where TSTAMP in (to_date('01-JUN-2010'),
3 to_date('01-JUL-2010'));
select count(*) from DEMO
*
ERROR at line 1:
ORA-00376: file 4 cannot be read at this time
ORA-01110: data file 4: 'C:\ORACLE\DB11\USERS01.DBF'
![Page 305: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/305.jpg)
305
"NO OP" pruning
![Page 306: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/306.jpg)
306
SQL> select * from DEMO
2 where TSTAMP = to_date('01-JUN-2020');
--------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
--------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE EMPTY| | 1 |INVALID|INVALID|
|* 2 | TABLE ACCESS FULL | DEMO | 1 |INVALID|INVALID|
--------------------------------------------------------------
![Page 307: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/307.jpg)
307
pruning lists
![Page 308: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/308.jpg)
308
SQL> create table SALES
2 ( sales_id varchar2(10) not null,
3 location varchar2(3) not null,
4 amount number(10)
5 )
6 PARTITION BY LIST (location)
7 (
8 PARTITION NSW VALUES ('NSW'),
9 PARTITION WA VALUES ('WA'),
10 PARTITION QLD VALUES ('QLD'),
11 PARTITION SA VALUES ('SA'),
12 PARTITION VIC VALUES ('VIC'),
13 PARTITION TERR VALUES ('ACT','NT')
14 )
15 /
Table created.
![Page 309: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/309.jpg)
309
SQL> select * from sales
2 where location = 'WA';
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION LIST SINGLE| | 1 | KEY | KEY |
| 2 | TABLE ACCESS FULL | SALES | 1 | 2 | 2 |
---------------------------------------------------------------
![Page 310: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/310.jpg)
310
SQL> select * from sales
2 where location like 'S%';
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION LIST SINGLE| | 1 | KEY | KEY |
| 2 | TABLE ACCESS FULL | SALES | 1 | 4 | 4 |
---------------------------------------------------------------
![Page 311: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/311.jpg)
311
SQL> select * from sales
2 where location NOT in ('WA','NSW');
------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION LIST ALL| | 1 | 1 | 6 |
|* 2 | TABLE ACCESS FULL| SALES | 1 | 1 | 6 |
------------------------------------------------------------
![Page 312: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/312.jpg)
312
pruning composites
![Page 313: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/313.jpg)
313
SQL> create table COMP
2 ( tstamp timestamp(6) not null,
3 empno number(10) not null,
4 ename varchar2(10) not null,
5 deptno varchar2(10) not null
6 )
7 PARTITION BY RANGE (TSTAMP)
8 SUBPARTITION BY LIST (deptno)
9 SUBPARTITION TEMPLATE
10 (SUBPARTITION d1 VALUES (1),
11 SUBPARTITION d2 VALUES (2),
12 SUBPARTITION d3 VALUES (3),
13 SUBPARTITION d4 VALUES (4))
14 (
15 PARTITION p01 VALUES LESS THAN
16 (TIMESTAMP' 2010-01-01 00:00:00'),
17 PARTITION p02 VALUES LESS THAN
18 (TIMESTAMP' 2010-02-01 00:00:00'),
19 ....
![Page 314: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/314.jpg)
314
SQL> select * from COMP
2 where TSTAMP = to_date('01-JUN-2010')
3 and DEPTNO = 2;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | |
| 1 | PARTITION RANGE SINGLE| | 1 | 7 | 7 |
| 2 | PARTITION LIST SINGLE| | 1 | 2 | 2 |
|* 3 | TABLE ACCESS FULL | COMP | 1 | 26 | 26 |
---------------------------------------------------------------
![Page 315: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/315.jpg)
315
SQL> select * from COMP
2 where DEPTNO = 3;
---------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
---------------------------------------------------------------
| 0 | SELECT STATEMENT | | 250K| | |
| 1 | PARTITION RANGE ALL | | 250K| 1 | 13 |
| 2 | PARTITION LIST SINGLE| | 250K| 3 | 3 |
| 3 | TABLE ACCESS FULL | COMP | 250K| KEY | KEY |
---------------------------------------------------------------
![Page 316: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/316.jpg)
316
pruning by subquery
![Page 317: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/317.jpg)
317
SQL> select e.deptno, max(d.empno)
2 from DEMO d, scott.emp e
3 where d.tstamp = e.hiredate
4 and e.sal < 10000
5 group by e.deptno;
-------------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
-------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 14 | | |
| 1 | HASH GROUP BY | | 14 | | |
|* 2 | HASH JOIN | | 14 | | |
|* 3 | TABLE ACCESS FULL | EMP | 14 | | |
| 4 | PARTITION RANGE SUBQUERY| | 1000K|KEY(SQ)|KEY(SQ)|
| 5 | TABLE ACCESS FULL | DEMO | 1000K|KEY(SQ)|KEY(SQ)|
-------------------------------------------------------------------
![Page 318: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/318.jpg)
11g
318
maybe 10.2 ?
![Page 319: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/319.jpg)
319
SQL> select e.deptno, max(d.empno)
2 from demo d, scott.emp e
3 where d.tstamp = e.hiredate
4 and e.sal < 10000
5 group by e.deptno;
-----------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
-----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | HASH GROUP BY | | | |
|* 2 | HASH JOIN | | | |
| 3 | PART JOIN FILTER CREATE | :BF0000 | | |
|* 4 | TABLE ACCESS FULL | EMP | | |
| 5 | PARTITION RANGE JOIN-FILTER| |:BF0000|:BF0000|
| 6 | TABLE ACCESS FULL | DEMO |:BF0000|:BF0000|
-----------------------------------------------------------------
![Page 320: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/320.jpg)
320
| 3 | PART JOIN FILTER CREATE | :BF0000 | | |
|* 4 | TABLE ACCESS FULL | EMP | | |
| 5 | PARTITION RANGE JOIN-FILTER| |:BF0000|:BF0000|
| 6 | TABLE ACCESS FULL | DEMO |:BF0000|:BF0000|
-----------------------------------------------------------------
huh ?
![Page 321: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/321.jpg)
bloom filters
321
![Page 322: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/322.jpg)
The Bloom filter...is a space-efficient probabilistic data structure that is used to test whether an element is
a member of a set.
- Wikipedia
322
![Page 323: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/323.jpg)
323
wtf ?
![Page 324: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/324.jpg)
324
"b" bits
"h" hash functions
![Page 325: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/325.jpg)
325
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
![Page 326: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/326.jpg)
326
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
![Page 327: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/327.jpg)
327
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
![Page 328: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/328.jpg)
328
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
![Page 329: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/329.jpg)
329
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
![Page 330: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/330.jpg)
330
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
![Page 331: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/331.jpg)
331
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
do the
"real"
work
![Page 332: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/332.jpg)
332
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
do the
"real"
work
![Page 333: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/333.jpg)
333
"meta-poor"
![Page 334: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/334.jpg)
334
![Page 335: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/335.jpg)
335
![Page 336: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/336.jpg)
336
"are you joking...try in 6 months"
![Page 337: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/337.jpg)
337
"yes, we have some"
![Page 338: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/338.jpg)
338
![Page 339: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/339.jpg)
339
false positives possible
![Page 340: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/340.jpg)
340
false negatives impossible
![Page 341: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/341.jpg)
341
they are here to stay....
![Page 342: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/342.jpg)
342
SQL> alter session set "_bloom_filter_enabled" = false;
SQL> alter session set "_bloom_pruning_enabled" = false;
![Page 343: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/343.jpg)
343
other partitioning benefits
![Page 344: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/344.jpg)
344
partition wise join
![Page 345: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/345.jpg)
345
SQL> select d.*, d2.*
2 from DEMO d, DEMO2 d2
3 where d.TSTAMP = d2.TSTAMP;
-------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
-------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1003K| | |
| 1 | PARTITION RANGE ALL| | 1003K| 1 | 13 |
|* 2 | HASH JOIN | | 1003K| | |
| 3 | TABLE ACCESS FULL| DEMO | 1000K| 1 | 13 |
| 4 | TABLE ACCESS FULL| DEMO2 | 1000K| 1 | 13 |
-------------------------------------------------------------
![Page 346: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/346.jpg)
346
"big deal"
![Page 347: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/347.jpg)
347
meta-poor
![Page 348: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/348.jpg)
348
![Page 349: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/349.jpg)
349
1000 cars north of Perth
1000 cars south of Perth
![Page 350: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/350.jpg)
350
![Page 351: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/351.jpg)
351
"replace damaged modelsat the north yard with matching
models from the south yard"
![Page 352: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/352.jpg)
352
![Page 353: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/353.jpg)
353
SQL> select ...
2 from NORTH n, SOUTH s
3 where n.MODEL = s.MODEL
----------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
|* 1 | HASH JOIN | | | |
| 3 | PARTITION RANGE ALL | | 1 | 2 |
| 4 | TABLE ACCESS FULL | NORTH | 1 | 2 |
| 5 | PARTITION RANGE ALL | | 1 | 2 |
| 6 | TABLE ACCESS FULL | SOUTH | 1 | 2 |
----------------------------------------------------------------
![Page 354: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/354.jpg)
354
NORTH
SOUTH
4WD SMART CARS
4WD SMART CARS
![Page 355: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/355.jpg)
355
partition wise join
![Page 356: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/356.jpg)
356
SQL> select ...
2 from NORTH n, SOUTH s
3 where n.model = s.model
-------------------------------------------------------------
| Id | Operation | Name | Rows | Pstart| Pstop |
-------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1003K| | |
| 1 | PARTITION RANGE ALL| | 1003K| 1 | 2 |
|* 2 | HASH JOIN | | 1003K| | |
| 3 | TABLE ACCESS FULL| NORTH | 1000K| 1 | 2 |
| 4 | TABLE ACCESS FULL| SOUTH | 1000K| 1 | 2 |
-------------------------------------------------------------
![Page 357: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/357.jpg)
357
great parallel benefits
![Page 358: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/358.jpg)
358
SQL> select /*+ PARALLEL(n) PARALLEL(s) */ ...
2 from north n, south s
3 where n.model = s.model
----------------------------------------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | | | |
| 1 | PX COORDINATOR | | | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10001 | | | Q1,01 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | | | Q1,01 | PCWP | |
| 4 | PX BLOCK ITERATOR | | 1 | 2 | Q1,01 | PCWC | |
| 5 | TABLE ACCESS FULL | NORTH | 1 | 2 | Q1,01 | PCWP | |
| 6 | BUFFER SORT | | | | Q1,01 | PCWC | |
| 7 | PX RECEIVE | | | | Q1,01 | PCWP | |
| 8 | PX SEND BROADCAST LOCAL| :TQ10000 | | | Q1,00 | P->P | BCST LOCAL |
| 9 | PX BLOCK ITERATOR | | 1 | 2 | Q1,00 | PCWC | |
| 10 | TABLE ACCESS FULL | SOUTH | 1 | 2 | Q1,00 | PCWP | |
----------------------------------------------------------------------------------------------
![Page 359: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/359.jpg)
359
NORTH
SOUTH
4WD SMART CARS
4WD SMART CARS
Slave 1 Slave 2
Slave 3 Slave 4
![Page 360: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/360.jpg)
360
partitions must match exactly
![Page 361: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/361.jpg)
361
if not, better in 11g
![Page 362: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/362.jpg)
362
fallback to bloom filter
![Page 363: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/363.jpg)
363
SQL> select ...
2 from NORTH n, SOUTH s
3 where n.model = s.model
----------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
|* 1 | HASH JOIN | | | |
| 2 | PART JOIN FILTER CREATE | :BF0000 | | |
| 3 | PARTITION RANGE ALL | | 1 | 2 |
| 4 | TABLE ACCESS FULL | NORTH | 1 | 2 |
| 5 | PARTITION RANGE JOIN-FILTER| |:BF0000|:BF0000|
| 6 | TABLE ACCESS FULL | SOUTH |:BF0000|:BF0000|
----------------------------------------------------------------
![Page 364: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/364.jpg)
364
if nececssary, brew your own
don't assume
![Page 365: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/365.jpg)
365
![Page 366: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/366.jpg)
wrap up
366
![Page 367: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/367.jpg)
all positive
367
![Page 368: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/368.jpg)
know the pitfalls
368
![Page 369: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/369.jpg)
pitfalls # 1
369
![Page 370: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/370.jpg)
370
SQL> select * from v$option;
PARAMETER VALUE
-------------------------------------------------- --------
Partitioning TRUE
Objects TRUE
Real Application Clusters TRUE
Advanced replication TRUE
Bit-mapped indexes TRUE
Connection multiplexing TRUE
Connection pooling TRUE
Database queuing TRUE
Incremental backup and recovery TRUE
Instead-of triggers TRUE
Parallel backup and recovery TRUE
Parallel execution TRUE
Parallel load TRUE
![Page 371: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/371.jpg)
![Page 372: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/372.jpg)
even in EE
372
![Page 373: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/373.jpg)
worth the cost....
373
![Page 374: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/374.jpg)
pitfalls # 2
374
![Page 375: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/375.jpg)
boundary cases
375
constraint validation
![Page 376: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/376.jpg)
boundary cases
376
statistics gathering
![Page 377: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/377.jpg)
boundary cases
377
shared pool
![Page 378: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/378.jpg)
boundary cases
378
reference partitions
![Page 379: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/379.jpg)
test with sql trace
379
![Page 380: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/380.jpg)
Connor McDonald
OracleDBA
co
.uk
380
![Page 381: Connor McDonald Partitioning](https://reader034.vdocuments.site/reader034/viewer/2022042505/54c6da494a7959dc018b4593/html5/thumbnails/381.jpg)
381
ORA-00041
www.oracledba.co.uk
“active time limit exceeded - session terminated”