SlideShare a Scribd company logo
1 of 287
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Typical speaker ego slide
youtube tinyurl.com/connor-tube
blog connor-mcdonald.com
twitter @connor_mc_d
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 4
asktom.oracle.com
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Partitioning 101
Connor McDonald
Developer Advocate
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
before we get started
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |7
Dump of memory from 0x07246400 to 0x07248400
1064B4C00 06A20000 08C0000A 0A07C47E 00020506 [...........~....]
1064B4C10 34BC0000 01000000 00030CBF 0A07C47C [4..............|]
1064B4C20 0002EC28 00020300 00000000 0004001D [...(............]
...
1064B6BF0 C10B02C1 0B06436F 6E6E6F72 C47E0605 [......Connor.~..]
table or index
block size
database version created in
relative block address
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
why ?
8
...now
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
version 8.0
9
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Partitioning 101
Connor McDonald
Developer Advocate
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
today...
11
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
big data
12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What Makes it Big Data?
VOLUME VELOCITY VARIETY VALUE
SOCIAL
BLOG
SMART
METER
1011001010010
0100110101010
1011100101010
100100101
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
before "Big Data"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
before the four V's
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Big Data"My is getting too damn !"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
the four V'sthe six P's
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
painful to backup
painful to manage
painful performance
probably partition
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Partitioning 101
Connor McDonald
Developer Advocate
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 21
Part 1
partitioned tables
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 22
range partitioning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 23
2009 2010 2011 2012
SALES
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 24
"all applications are (time)
windows on data"
http://thehelsinkideclaration.blogspot.com/
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 25
corollary:
everyone can benefit
from (time) range partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 26
time the most common
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 27
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 28
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'
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
range partition boundaries
29
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 30
split by upper bound
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 31
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32
possible benefits
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 33
performance
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 34
partition pruning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 35
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 |
---------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 36
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'
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 37
more later...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 38
maintenance
add / drop
move
rebuild
backup / read-only
compress
cache control
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 39
availability
recovery
partition loss
a little dubious....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 40
multi-column range
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 41
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 42
tiebreaker ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 43
... not multi dimension
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 44
hash partitioning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 45
big stuff is a pain
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 47
For younger audience members:
The phone book is an ancient device used by
your ancestors to discover the contact
information for a friend, relative, or business
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 49
possible benefits
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 50
manageability
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 51
move
backup
etc
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 52
insertion
performance
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 53
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 54
less relevant nowadays
for tables
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 55
ASSM
automatic
segment
space
management
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 56
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 57
...but still important
see later
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 58
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 8
5 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 59
even spread of values
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 60
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 61
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 62
predicting hash target
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
remember these
63
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 64
the power of 2 rule
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 65
SQL> create table T
2 ( x number(10) )
3 partition by hash ( x )
4 partitions 4 | 8 | 16 | 32 ...
5 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 66
why ?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 67
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 68
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
huh ?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 69
deliberately
for maintenance...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 70
Task:
from 5 to 8 partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 71
"classical" redistribution
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 72
~every row moves
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 73
SQL> select count(*)
2 from T
3 where ora_hash(x,4) != ora_hash(x,7);
COUNT(*)
----------
87564
out of 100,000 rows
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 74
smart redistribution
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 75
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 76
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 77
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 78
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 79
only 1 partition effort
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 80
handling a small number of values
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 81
range fiddly....
SQL> create table ...
...
20 values less than ('CAS'),
21 values less than ('MTS'),
22 values less than ('NWFC'),
23 values less than ('TAXJ'),
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 82
SQL> select distinct mode
2 from TRANSPORT;
SPORT
------
CAR
MTR
NWFB
TAXI
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 83
hash ... poor distribution
SQL> select mode, ora_hash(mode,3) hash
2 from transport;
MODE HASH
------ ----
CAR 3
MTR 3
NWFB 2
TAX 2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 84
list
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 85
SQL> create table TRANSPORT
2 ( trans_id varchar2(10) not null,
3 mode varchar2(10) not null,
4 ...
5 )
6 PARTITION BY LIST (mode)
7 (
8 PARTITION P_CAR VALUES ('CAR'),
9 PARTITION P_MTR VALUES ('MTR'),
10 PARTITION P_NWFB VALUES ('NWFB'),
11 PARTITION P_TAXI VALUES ('TAXI'),
12 PARTITION WHO_CARES VALUES ('WALK','RUN',...)
13 )
14 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 86
SQL> create table TRANSPORT
2 ( trans_id varchar2(10) not null,
3 mode varchar2(10) not null,
4 ...
5 )
6 PARTITION BY LIST (mode)
7 (
8 PARTITION P_CAR VALUES ('CAR'),
9 PARTITION P_MTR VALUES ('MTR'),
10 PARTITION P_NWFB VALUES ('NWFB'),
11 PARTITION P_TAXI VALUES ('TAXI'),
12 PARTITION WHO_CARES VALUES (DEFAULT)
13 )
14 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 87
think carefully on DEFAULT
add versus split
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 88
sometimes one level is not enough
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 90
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 91
ranges unevenly distributed
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 92
deletion of older data
2009
2010
2011 2012
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 93
composite partitions
range + hash
range + list
anything + anything
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 94
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)),
.....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 95
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')
.....
coalesce / merge
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 96
long DDL .....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 97
subpartition templates
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 98
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 99
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'
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 100
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'
...
auto named for
subpar templates
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 101
partitions
logical or physical
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 102
interval partitioning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 103
the problem with ranges....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 104
... they are a (finite) range
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 105
SQL> create table SALES
2 ( cal_year date,
3 txn_id int,
...
...
24 )
25 partition by range ( cal_year )
26 (
27 partition p_low values less than ( date '2000-01-01' ),
28 partition p2000 values less than ( date '2001-01-01' ),
...
...
34 partition p2016 values less than ( date '2017-01-01' )
35 );
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 106
SQL> insert into SALES
2 values ( trunc(sysdate), .... );
insert into SALES
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 107
insurance policy
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 108
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 109
why MAXVALUE might hurt
part 1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 110
split not add
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 111
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 112
index hassles
see later...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 113
a better solution
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 114
interval partitioning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 115
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 116
partitions created as required
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 117
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'),....);
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'
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 118
gaps allowed
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
range partition boundaries
119
Length Length Length
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 120
partition name control lost
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 121
SQL> alter table DEMO partition ??? move;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 122
can rename …
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 123
can use FOR syntax
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 124
SQL> alter table DEMO partition
2 FOR ( TIMESTAMP' 2012-02-01 05:30:00')
3 move
4 /
Table altered.
not the upper bound
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 125
existing range tables ?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 126
convert range to interval
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 127
SQL> alter table MY_RANGE_TABLE
2 SET INTERVAL ( NUMTOYMINTERVAL(1,'MONTH') );
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 128
SQL> insert into MY_RANGE_TABLE
2 values ( to_date('01-JAN-2017'),....);
1 row created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 129
SQL> select partition_name pname,
2 partition_position pos,
3 high_value
4 from user_tab_partitions
5 where table_name = 'MY_RANGE_TABLE';
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'
...
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'
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 130
but be careful ...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 131
high range value is a marker
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 132
Length Length Length
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 133
SQL> select partition_name pname,
2 partition_position pos,
3 high_value, interval
4 from user_tab_partitions
5 where table_name = 'DEMO';
PNAME POS HIGH_VALUE INTERVAL
------------ ---------- ------------------------------- --------
P01 1 TIMESTAMP' 2010-01-01 00:00:00' NO
P02 2 TIMESTAMP' 2010-02-01 00:00:00' NO
P03 3 TIMESTAMP' 2010-03-01 00:00:00' NO
P04 4 TIMESTAMP' 2010-04-01 00:00:00' NO
...
P13 13 TIMESTAMP' 2011-01-01 00:00:00' NO
SYS_P1112 14 TIMESTAMP' 2016-02-01 00:00:00' YES
SYS_P1111 15 TIMESTAMP' 2017-02-01 00:00:00' YES
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 134
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 135
fixed in 12.2+
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 136
before 12.2 .... "re-range"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 137
SQL> alter table DEMO
2 set interval (NUMTOYMINTERVAL(1,'MONTH'));
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 138
why MAXVALUE might hurt
part 2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 139
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 140
SQL> alter table DEMO
2 set interval ( NUMTOYMINTERVAL(1,'MONTH') );
*
ERROR at line 1:
ORA-14759: SET INTERVAL is not legal on this table.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 141
12.2, "interval" for lists
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 142
automatic lists
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 143
SQL> create table PEOPLE
2 (
3 id int,
4 forename varchar2(30),
5 surname varchar2(30),
6 gender varchar2(1)
7 )
8 partition by list (gender) automatic
9 (
10 partition male values ('M'),
11 partition female values ('F')
12 );
Table created. must still be >=1
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 144
SQL> insert into PEOPLE
2 values ( 1,'Connor','McDonald','U');
1 row created.
SQL> select partition_name
2 from user_tab_partitions
3 where table_name = 'PEOPLE';
PARTITION_NAME
-------------------------------------------------
FEMALE
MALE
SYS_P661
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 145
partitioned tables ...
the bigger picture
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 146
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
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 147
reference partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 148
SQL> create table PARENT
2 ( dte date not null,
3 pk number(10) not null,
4 pad char(10)
5 )
6 PARTITION BY RANGE (dte)
7 (
8 PARTITION p1 VALUES LESS THAN ( to_date('01-JAN-2010')),
9 PARTITION p2 VALUES LESS THAN ( to_date('01-FEB-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 ( pk );
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 149
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 (pk)
6 on delete cascade
7 )
8 PARTITION BY REFERENCE (CHILD_FK)
9 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 150
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 151
SQL> exec dbms_stats.gather_table_stats(user,'CHILD');
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 152
Part 2
indexes on partitioned tables
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 153
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 154
2009 2010 2011 2012
SALES
SQL> create index SALES_IX on SALES ( CUSTOMER );
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 155
2009 2010 2011 2012
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 156
global index
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 157
big....really big
extended rowid
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 158
ILM issues
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 159
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 160
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 | | |
---------------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 161
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 |
------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 162
SQL> select value
2 from v$parameter
3 where name = 'skip_unusable_indexes';
VALUE
------------------------------
TRUE
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 163
keep the index valid
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 164
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009
2 update indexes;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 165
 large delete
redo
undo
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 166
much better in 12c+
asynch cleanup
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 167
2009 2010 2011 2012
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 168
an alternative
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 169
local index
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 170
2009 2010 2011 2012
SQL> create index SALES_IX ON SALES ( CUSTOMER )
2 LOCAL;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 171
smaller chunks
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 172
2009 2010 2011 2012
SQL> alter table SALES drop partition SALES_2009;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 173
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
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 174
SQL> alter table DEMO drop partition P04;
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
P05 USABLE
P06 USABLE
P07 USABLE
...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 175
awesome for ILM
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 176
handling old data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 177
2009 2010 2011 2012
SQL> alter table SALES move partition SALES_2009
2 COMPRESS;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 178
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 179
combine with deferred segments
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 180
2009 2010 2011 2012
SQL> alter index SALES_IX partition SALES_IX_2009
2 UNUSABLE;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 181
or in 12c
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 182
2009 2010 2011 2012
SQL> alter table SALES modify partition SALES_2009
2 INDEXING OFF;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 183
or the opposite
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 184
2009 2010 2011 2012
SQL> alter table SALES modify partition SALES_2012
2 INDEXING OFF;
2012
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 185
handling new data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 186
2010 2011 201220132013
SQL> alter table SALES exchange
2 partition SALES_2013 with
3 table NEW_SALES;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
local = goodlocal = good
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 188
global = badglobal = bad
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 189
nope :-)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 190
different usage models
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 191
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;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 192
or worse...
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 193
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123;
CAR TAXI
NWFB MTR
CAR TAXI
NWFB MTR
CAR TAXI
NWFB MTR
CAR TAXI
NWFB MTR
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 194
explain plan
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 195
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 |
----------------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 196
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123;
123123123123
SQL> create index SALES_IX on SALES ( CUSTOMER ) LOCAL;
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 197
"so global for index lookups then"....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 198
nope :-)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 199
2009 2010 2011 2012
SQL> select *
2 from SALES
3 where CUSTOMER = 123
4 and YEAR = 2010;
123
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 200
careful design
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 201
application compromises
eg unique keys
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 202
more partitioning options
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 203
SALES
SQL> create index SALES_IX ON SALES ( CUSTOMER )
2 global
3 partition by ....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 204
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 );
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 205
rare ....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 206
...one special case
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 207
hash partitioned index
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 208
recall: hash partitioned tables
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 209
concurrencyASSM
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 210
indexes a problem
ascending key
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 211
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 212
hash partitioned indexes
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 213
SQL> create index SALES_PK on SALES( TXN_ID )
2 global partition by hash ( TXN_ID )
3 partitions 8
4 /
Index created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 214
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 215
Part 3
partition queries
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 216
partition pruning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 217
query efficiency =
data required /
data scanned
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 218
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.
monthly
partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 219
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.
1m rows over
360 days
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 220
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 |
---------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 221
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 |
------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 222
works with binds too
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 223
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 |
---------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 224
lots of power
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 225
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)|
-----------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 226
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) |
---------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 227
limitations of explain plan
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 228
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 229
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
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 230
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:ORACLEDB12USERS01.DBF'
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 231
interval partition idiosyncracy
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 232
INTERVAL = 1 million potential partitions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 233
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.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 234
SQL> select * from DEMO; --empty
------------------------------------------------------------
| 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|
------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 235
NO OP pruning
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 236
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|
--------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 237
pruning composites
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 238
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 ....
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 239
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 |
---------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 240
pruning by subquery
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 241
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|
-----------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 242
huh ?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
bloom filters
243
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
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
244
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 245
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 246
"b" bits
"h" hash functions
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 247
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 248
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 249
b0
b1
b2
b3
b4
b6
b7
h1
h2
h3
data
b5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 250
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 251
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
data
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 252
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 253
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
do the "real" work
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 254
b0
b1
b2
b3
b4
b5
b6
b7
h1
h2
h3
matching
data?
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 255
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 256
metaphor
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 257
"phone in advance"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 258
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 259
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 260
"Are you serious !? Try in 6 months"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 261
"There's a few seats left..."
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 262
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 263
false positives possible
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 264
false negatives impossible
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 265
other partitioning benefits
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 266
partition wise join
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 267
"big deal"
join the partitions
join the table
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 268
our last metaphor :-)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 269
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 270
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 271
match the pairs
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 272
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 273
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 274
SQL> select ...
2 from SOCKS n, SOCKS s
3 where n.STYLE_SIZE = s.STYLE_SIZE
----------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
----------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
|* 1 | HASH JOIN | | | |
| 3 | PARTITION RANGE ALL | | 1 | 2 |
| 4 | TABLE ACCESS FULL | WHITE | 1 | 2 |
| 5 | PARTITION RANGE ALL | | 1 | 2 |
| 6 | TABLE ACCESS FULL | BLACK | 1 | 2 |
----------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 275
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 |
-------------------------------------------------------------
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
wrap up
276
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
lots of potential ...
277
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
benefits in many places
278
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
"yeah but"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
painful to backup
painful to manage
painful performance
probably partition
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
the two O's
"Oh crap ... we will need an Outage"
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
partition existing table
12.2
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 283
SQL> create table T as
2 select d.*
3 from dba_Objects d,
4 ( select 1 from dual
5 connect by level <= 20 )
6 where d.object_id is not null;
Table created.
SQL> create index IX on t ( object_id );
Index created.
SQL> create index IX2 on t ( created, object_name );
Index created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 284
SQL> alter table T modify
2 partition by range (object_id) interval (10000)
3 (
4 partition p1 values less than (20000) compress
5 ) online
6 including rows where created > date '2010-01-01'
7 update indexes
8 ( ix local tablespace new_idx_ts,
9 ix2 global partition by range (created)
10 (
11 partition ix2_p1 values less than (date '2016-08-01'),
12 partition ix2_p2 values less than (maxvalue)
13 )
14 );
Table altered.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
did you notice ?
285
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 286
SQL> create table HKOUG_PRESENTATION
2 ( ...
3 ...
4 ...
5 )
6 PARTITION BY LIST (topic)
7 (
8 PARTITION PART1 VALUES ('TABLES'),
9 PARTITION PART2 VALUES ('INDEXES'),
10 PARTITION PART3 VALUES ('QUERIES')
11 );
11 /
Table created.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Thank you for your time
youtube tinyurl.com/connor-tube
blog connor-mcdonald.com
twitter @connor_mc_d

More Related Content

Similar to Partitioning 101 Breakdown

Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLConnor McDonald
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cHyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cConnor McDonald
 
Melbourne Groundbreakers Tour - Upgrading without risk
Melbourne Groundbreakers Tour - Upgrading without riskMelbourne Groundbreakers Tour - Upgrading without risk
Melbourne Groundbreakers Tour - Upgrading without riskConnor McDonald
 
Sangam 18 - The New Optimizer in Oracle 12c
Sangam 18 - The New Optimizer in Oracle 12cSangam 18 - The New Optimizer in Oracle 12c
Sangam 18 - The New Optimizer in Oracle 12cConnor McDonald
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...GeneXus
 
Perth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresPerth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresConnor McDonald
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMayank Prasad
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAsConnor McDonald
 
10 Razões para Usar MySQL em Startups
10 Razões para Usar MySQL em Startups10 Razões para Usar MySQL em Startups
10 Razões para Usar MySQL em StartupsMySQL Brasil
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerWellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerConnor McDonald
 
Oracle on Oracle (OoO)
Oracle on Oracle (OoO)Oracle on Oracle (OoO)
Oracle on Oracle (OoO)Oracle
 
OSC Online MySQL Version up
OSC Online MySQL Version upOSC Online MySQL Version up
OSC Online MySQL Version upDAISUKE INAGAKI
 
Backup and Recovery in MySQL Cluster
Backup and Recovery in MySQL ClusterBackup and Recovery in MySQL Cluster
Backup and Recovery in MySQL Clusterpriyanka_sangam
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesDLT Solutions
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowAlex Zaballa
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesGuatemala User Group
 
Oracle OpenWorld - Getting started with MySQL Cluster
Oracle OpenWorld - Getting started with MySQL ClusterOracle OpenWorld - Getting started with MySQL Cluster
Oracle OpenWorld - Getting started with MySQL ClusterBenedita Paúl Vasconcelos
 
Using Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesUsing Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesAnil Nair
 

Similar to Partitioning 101 Breakdown (20)

Five more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQLFive more things about Oracle SQL and PLSQL
Five more things about Oracle SQL and PLSQL
 
Hyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19cHyderabad Mar 2019 - Database 18c / 19c
Hyderabad Mar 2019 - Database 18c / 19c
 
Cool SQL Features
Cool SQL FeaturesCool SQL Features
Cool SQL Features
 
JavaMicroBenchmarkpptm
JavaMicroBenchmarkpptmJavaMicroBenchmarkpptm
JavaMicroBenchmarkpptm
 
Melbourne Groundbreakers Tour - Upgrading without risk
Melbourne Groundbreakers Tour - Upgrading without riskMelbourne Groundbreakers Tour - Upgrading without risk
Melbourne Groundbreakers Tour - Upgrading without risk
 
Sangam 18 - The New Optimizer in Oracle 12c
Sangam 18 - The New Optimizer in Oracle 12cSangam 18 - The New Optimizer in Oracle 12c
Sangam 18 - The New Optimizer in Oracle 12c
 
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
MySQL 20 años: pasado, presente y futuro; conoce las nuevas características d...
 
Perth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c featuresPerth APAC Groundbreakers tour - 18c features
Perth APAC Groundbreakers tour - 18c features
 
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRsMySQL-Performance Schema- What's new in MySQL-5.7 DMRs
MySQL-Performance Schema- What's new in MySQL-5.7 DMRs
 
18c and 19c features for DBAs
18c and 19c features for DBAs18c and 19c features for DBAs
18c and 19c features for DBAs
 
10 Razões para Usar MySQL em Startups
10 Razões para Usar MySQL em Startups10 Razões para Usar MySQL em Startups
10 Razões para Usar MySQL em Startups
 
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c OptimizerWellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
Wellington APAC Groundbreakers tour - Upgrading to the 12c Optimizer
 
Oracle on Oracle (OoO)
Oracle on Oracle (OoO)Oracle on Oracle (OoO)
Oracle on Oracle (OoO)
 
OSC Online MySQL Version up
OSC Online MySQL Version upOSC Online MySQL Version up
OSC Online MySQL Version up
 
Backup and Recovery in MySQL Cluster
Backup and Recovery in MySQL ClusterBackup and Recovery in MySQL Cluster
Backup and Recovery in MySQL Cluster
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of Databases
 
DBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should KnowDBA Commands and Concepts That Every Developer Should Know
DBA Commands and Concepts That Every Developer Should Know
 
How to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of DatabasesHow to Upgrade Hundreds or Thousands of Databases
How to Upgrade Hundreds or Thousands of Databases
 
Oracle OpenWorld - Getting started with MySQL Cluster
Oracle OpenWorld - Getting started with MySQL ClusterOracle OpenWorld - Getting started with MySQL Cluster
Oracle OpenWorld - Getting started with MySQL Cluster
 
Using Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC IssuesUsing Machine Learning to Debug Oracle RAC Issues
Using Machine Learning to Debug Oracle RAC Issues
 

More from Connor McDonald

Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestConnor McDonald
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQLConnor McDonald
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsConnor McDonald
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousConnor McDonald
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesConnor McDonald
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresConnor McDonald
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousConnor McDonald
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne Connor McDonald
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsConnor McDonald
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistencyConnor McDonald
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsConnor McDonald
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessionsConnor McDonald
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresConnor McDonald
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featuesConnor McDonald
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - FlashbackConnor McDonald
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql featuresConnor McDonald
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingConnor McDonald
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processingConnor McDonald
 

More from Connor McDonald (20)

Flashback ITOUG
Flashback ITOUGFlashback ITOUG
Flashback ITOUG
 
Sangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolestSangam 19 - PLSQL still the coolest
Sangam 19 - PLSQL still the coolest
 
Sangam 19 - Analytic SQL
Sangam 19 - Analytic SQLSangam 19 - Analytic SQL
Sangam 19 - Analytic SQL
 
UKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tipsUKOUG - 25 years of hints and tips
UKOUG - 25 years of hints and tips
 
Sangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on AutonomousSangam 19 - Successful Applications on Autonomous
Sangam 19 - Successful Applications on Autonomous
 
Sangam 2019 - The Latest Features
Sangam 2019 - The Latest FeaturesSangam 2019 - The Latest Features
Sangam 2019 - The Latest Features
 
UKOUG 2019 - SQL features
UKOUG 2019 - SQL featuresUKOUG 2019 - SQL features
UKOUG 2019 - SQL features
 
APEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomousAPEX tour 2019 - successful development with autonomous
APEX tour 2019 - successful development with autonomous
 
APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne APAC Groundbreakers 2019 - Perth/Melbourne
APAC Groundbreakers 2019 - Perth/Melbourne
 
OOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAsOOW19 - Flashback, not just for DBAs
OOW19 - Flashback, not just for DBAs
 
OOW19 - Read consistency
OOW19 - Read consistencyOOW19 - Read consistency
OOW19 - Read consistency
 
OOW19 - Slower and less secure applications
OOW19 - Slower and less secure applicationsOOW19 - Slower and less secure applications
OOW19 - Slower and less secure applications
 
OOW19 - Killing database sessions
OOW19 - Killing database sessionsOOW19 - Killing database sessions
OOW19 - Killing database sessions
 
OOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL featuresOOW19 - Ten Amazing SQL features
OOW19 - Ten Amazing SQL features
 
Latin America Tour 2019 - 18c and 19c featues
Latin America Tour 2019   - 18c and 19c featuesLatin America Tour 2019   - 18c and 19c featues
Latin America Tour 2019 - 18c and 19c featues
 
Latin America tour 2019 - Flashback
Latin America tour 2019 -  FlashbackLatin America tour 2019 -  Flashback
Latin America tour 2019 - Flashback
 
Latin America Tour 2019 - 10 great sql features
Latin America Tour 2019  - 10 great sql featuresLatin America Tour 2019  - 10 great sql features
Latin America Tour 2019 - 10 great sql features
 
Latin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matchingLatin America Tour 2019 - pattern matching
Latin America Tour 2019 - pattern matching
 
Latin America Tour 2019 - slow data and sql processing
Latin America Tour 2019  - slow data and sql processingLatin America Tour 2019  - slow data and sql processing
Latin America Tour 2019 - slow data and sql processing
 
ANSI vs Oracle language
ANSI vs Oracle languageANSI vs Oracle language
ANSI vs Oracle language
 

Recently uploaded

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Recently uploaded (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

Partitioning 101 Breakdown

  • 1.
  • 2. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 2
  • 3. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Typical speaker ego slide youtube tinyurl.com/connor-tube blog connor-mcdonald.com twitter @connor_mc_d
  • 4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 4 asktom.oracle.com
  • 5. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Partitioning 101 Connor McDonald Developer Advocate
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | before we get started 6
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |7 Dump of memory from 0x07246400 to 0x07248400 1064B4C00 06A20000 08C0000A 0A07C47E 00020506 [...........~....] 1064B4C10 34BC0000 01000000 00030CBF 0A07C47C [4..............|] 1064B4C20 0002EC28 00020300 00000000 0004001D [...(............] ... 1064B6BF0 C10B02C1 0B06436F 6E6E6F72 C47E0605 [......Connor.~..] table or index block size database version created in relative block address
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | why ? 8 ...now
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | version 8.0 9
  • 10. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Partitioning 101 Connor McDonald Developer Advocate
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | today... 11
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | big data 12
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What Makes it Big Data? VOLUME VELOCITY VARIETY VALUE SOCIAL BLOG SMART METER 1011001010010 0100110101010 1011100101010 100100101
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | before "Big Data"
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | before the four V's
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Big Data"My is getting too damn !"
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | the four V'sthe six P's
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | painful to backup painful to manage painful performance probably partition
  • 20. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Partitioning 101 Connor McDonald Developer Advocate
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 21 Part 1 partitioned tables
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 22 range partitioning
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 23 2009 2010 2011 2012 SALES
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 24 "all applications are (time) windows on data" http://thehelsinkideclaration.blogspot.com/
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 25 corollary: everyone can benefit from (time) range partitions
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 26 time the most common
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 27 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.
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 28 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' ...
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | range partition boundaries 29
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 30 split by upper bound
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 31 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
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 32 possible benefits
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 33 performance
  • 34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 34 partition pruning
  • 35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 35 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 | ---------------------------------------------------------------
  • 36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 36 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' ...
  • 37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 37 more later...
  • 38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 38 maintenance add / drop move rebuild backup / read-only compress cache control
  • 39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 39 availability recovery partition loss a little dubious....
  • 40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 40 multi-column range
  • 41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 41 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.
  • 42. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 42 tiebreaker ...
  • 43. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 43 ... not multi dimension
  • 44. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 44 hash partitioning
  • 45. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 45 big stuff is a pain
  • 46. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 47. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 47 For younger audience members: The phone book is an ancient device used by your ancestors to discover the contact information for a friend, relative, or business
  • 48. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 49. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 49 possible benefits
  • 50. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 50 manageability
  • 51. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 51 move backup etc
  • 52. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 52 insertion performance
  • 53. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 53
  • 54. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 54 less relevant nowadays for tables
  • 55. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 55 ASSM automatic segment space management
  • 56. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 56
  • 57. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 57 ...but still important see later
  • 58. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 58 SQL> create table T 2 ( x number(10) ) 3 partition by hash ( x ) 4 partitions 8 5 / Table created.
  • 59. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 59 even spread of values
  • 60. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 60 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
  • 61. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 61 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
  • 62. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 62 predicting hash target
  • 63. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | remember these 63 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
  • 64. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 64 the power of 2 rule
  • 65. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 65 SQL> create table T 2 ( x number(10) ) 3 partition by hash ( x ) 4 partitions 4 | 8 | 16 | 32 ... 5 / Table created.
  • 66. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 66 why ?
  • 67. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 67 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.
  • 68. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 68 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 huh ?
  • 69. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 69 deliberately for maintenance...
  • 70. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 70 Task: from 5 to 8 partitions
  • 71. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 71 "classical" redistribution
  • 72. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 72 ~every row moves
  • 73. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 73 SQL> select count(*) 2 from T 3 where ora_hash(x,4) != ora_hash(x,7); COUNT(*) ---------- 87564 out of 100,000 rows
  • 74. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 74 smart redistribution
  • 75. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 75 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
  • 76. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 76 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
  • 77. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 77 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
  • 78. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 78 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
  • 79. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 79 only 1 partition effort
  • 80. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 80 handling a small number of values
  • 81. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 81 range fiddly.... SQL> create table ... ... 20 values less than ('CAS'), 21 values less than ('MTS'), 22 values less than ('NWFC'), 23 values less than ('TAXJ'),
  • 82. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 82 SQL> select distinct mode 2 from TRANSPORT; SPORT ------ CAR MTR NWFB TAXI
  • 83. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 83 hash ... poor distribution SQL> select mode, ora_hash(mode,3) hash 2 from transport; MODE HASH ------ ---- CAR 3 MTR 3 NWFB 2 TAX 2
  • 84. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 84 list
  • 85. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 85 SQL> create table TRANSPORT 2 ( trans_id varchar2(10) not null, 3 mode varchar2(10) not null, 4 ... 5 ) 6 PARTITION BY LIST (mode) 7 ( 8 PARTITION P_CAR VALUES ('CAR'), 9 PARTITION P_MTR VALUES ('MTR'), 10 PARTITION P_NWFB VALUES ('NWFB'), 11 PARTITION P_TAXI VALUES ('TAXI'), 12 PARTITION WHO_CARES VALUES ('WALK','RUN',...) 13 ) 14 / Table created.
  • 86. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 86 SQL> create table TRANSPORT 2 ( trans_id varchar2(10) not null, 3 mode varchar2(10) not null, 4 ... 5 ) 6 PARTITION BY LIST (mode) 7 ( 8 PARTITION P_CAR VALUES ('CAR'), 9 PARTITION P_MTR VALUES ('MTR'), 10 PARTITION P_NWFB VALUES ('NWFB'), 11 PARTITION P_TAXI VALUES ('TAXI'), 12 PARTITION WHO_CARES VALUES (DEFAULT) 13 ) 14 / Table created.
  • 87. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 87 think carefully on DEFAULT add versus split
  • 88. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 88 sometimes one level is not enough
  • 89. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 90. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 90
  • 91. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 91 ranges unevenly distributed
  • 92. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 92 deletion of older data 2009 2010 2011 2012
  • 93. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 93 composite partitions range + hash range + list anything + anything
  • 94. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 94 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)), .....
  • 95. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 95 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') ..... coalesce / merge
  • 96. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 96 long DDL .....
  • 97. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 97 subpartition templates
  • 98. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 98 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
  • 99. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 99 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' ...
  • 100. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 100 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' ... auto named for subpar templates
  • 101. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 101 partitions logical or physical
  • 102. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 102 interval partitioning
  • 103. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 103 the problem with ranges....
  • 104. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 104 ... they are a (finite) range
  • 105. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 105 SQL> create table SALES 2 ( cal_year date, 3 txn_id int, ... ... 24 ) 25 partition by range ( cal_year ) 26 ( 27 partition p_low values less than ( date '2000-01-01' ), 28 partition p2000 values less than ( date '2001-01-01' ), ... ... 34 partition p2016 values less than ( date '2017-01-01' ) 35 ); Table created.
  • 106. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 106 SQL> insert into SALES 2 values ( trunc(sysdate), .... ); insert into SALES * ERROR at line 1: ORA-14400: inserted partition key does not map to any partition
  • 107. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 107 insurance policy
  • 108. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 108 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
  • 109. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 109 why MAXVALUE might hurt part 1
  • 110. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 110 split not add
  • 111. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 111 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.
  • 112. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 112 index hassles see later...
  • 113. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 113 a better solution
  • 114. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 114 interval partitioning
  • 115. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 115 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.
  • 116. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 116 partitions created as required
  • 117. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 117 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'),....); 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'
  • 118. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 118 gaps allowed
  • 119. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | range partition boundaries 119 Length Length Length
  • 120. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 120 partition name control lost
  • 121. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 121 SQL> alter table DEMO partition ??? move;
  • 122. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 122 can rename …
  • 123. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 123 can use FOR syntax
  • 124. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 124 SQL> alter table DEMO partition 2 FOR ( TIMESTAMP' 2012-02-01 05:30:00') 3 move 4 / Table altered. not the upper bound
  • 125. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 125 existing range tables ?
  • 126. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 126 convert range to interval
  • 127. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 127 SQL> alter table MY_RANGE_TABLE 2 SET INTERVAL ( NUMTOYMINTERVAL(1,'MONTH') ); Table altered.
  • 128. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 128 SQL> insert into MY_RANGE_TABLE 2 values ( to_date('01-JAN-2017'),....); 1 row created.
  • 129. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 129 SQL> select partition_name pname, 2 partition_position pos, 3 high_value 4 from user_tab_partitions 5 where table_name = 'MY_RANGE_TABLE'; 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' ... 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'
  • 130. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 130 but be careful ...
  • 131. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 131 high range value is a marker
  • 132. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 132 Length Length Length
  • 133. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 133 SQL> select partition_name pname, 2 partition_position pos, 3 high_value, interval 4 from user_tab_partitions 5 where table_name = 'DEMO'; PNAME POS HIGH_VALUE INTERVAL ------------ ---------- ------------------------------- -------- P01 1 TIMESTAMP' 2010-01-01 00:00:00' NO P02 2 TIMESTAMP' 2010-02-01 00:00:00' NO P03 3 TIMESTAMP' 2010-03-01 00:00:00' NO P04 4 TIMESTAMP' 2010-04-01 00:00:00' NO ... P13 13 TIMESTAMP' 2011-01-01 00:00:00' NO SYS_P1112 14 TIMESTAMP' 2016-02-01 00:00:00' YES SYS_P1111 15 TIMESTAMP' 2017-02-01 00:00:00' YES
  • 134. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 134 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
  • 135. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 135 fixed in 12.2+
  • 136. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 136 before 12.2 .... "re-range"
  • 137. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 137 SQL> alter table DEMO 2 set interval (NUMTOYMINTERVAL(1,'MONTH')); Table altered.
  • 138. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 138 why MAXVALUE might hurt part 2
  • 139. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 139 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.
  • 140. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 140 SQL> alter table DEMO 2 set interval ( NUMTOYMINTERVAL(1,'MONTH') ); * ERROR at line 1: ORA-14759: SET INTERVAL is not legal on this table.
  • 141. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 141 12.2, "interval" for lists
  • 142. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 142 automatic lists
  • 143. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 143 SQL> create table PEOPLE 2 ( 3 id int, 4 forename varchar2(30), 5 surname varchar2(30), 6 gender varchar2(1) 7 ) 8 partition by list (gender) automatic 9 ( 10 partition male values ('M'), 11 partition female values ('F') 12 ); Table created. must still be >=1
  • 144. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 144 SQL> insert into PEOPLE 2 values ( 1,'Connor','McDonald','U'); 1 row created. SQL> select partition_name 2 from user_tab_partitions 3 where table_name = 'PEOPLE'; PARTITION_NAME ------------------------------------------------- FEMALE MALE SYS_P661
  • 145. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 145 partitioned tables ... the bigger picture
  • 146. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 146 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 ...
  • 147. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 147 reference partitions
  • 148. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 148 SQL> create table PARENT 2 ( dte date not null, 3 pk number(10) not null, 4 pad char(10) 5 ) 6 PARTITION BY RANGE (dte) 7 ( 8 PARTITION p1 VALUES LESS THAN ( to_date('01-JAN-2010')), 9 PARTITION p2 VALUES LESS THAN ( to_date('01-FEB-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 ( pk ); Table altered.
  • 149. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 149 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 (pk) 6 on delete cascade 7 ) 8 PARTITION BY REFERENCE (CHILD_FK) 9 / Table created.
  • 150. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 150 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.
  • 151. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 151 SQL> exec dbms_stats.gather_table_stats(user,'CHILD'); 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
  • 152. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 152 Part 2 indexes on partitioned tables
  • 153. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 153
  • 154. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 154 2009 2010 2011 2012 SALES SQL> create index SALES_IX on SALES ( CUSTOMER );
  • 155. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 155 2009 2010 2011 2012
  • 156. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 156 global index
  • 157. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 157 big....really big extended rowid
  • 158. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 158 ILM issues
  • 159. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 159 2009 2010 2011 2012 SQL> alter table SALES drop partition SALES_2009
  • 160. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 160 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 | | | ---------------------------------------------------------------------
  • 161. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 161 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 | ------------------------------------------------------------
  • 162. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 162 SQL> select value 2 from v$parameter 3 where name = 'skip_unusable_indexes'; VALUE ------------------------------ TRUE
  • 163. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 163 keep the index valid
  • 164. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 164 2009 2010 2011 2012 SQL> alter table SALES drop partition SALES_2009 2 update indexes;
  • 165. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 165  large delete redo undo
  • 166. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 166 much better in 12c+ asynch cleanup
  • 167. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 167 2009 2010 2011 2012
  • 168. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 168 an alternative
  • 169. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 169 local index
  • 170. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 170 2009 2010 2011 2012 SQL> create index SALES_IX ON SALES ( CUSTOMER ) 2 LOCAL;
  • 171. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 171 smaller chunks
  • 172. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 172 2009 2010 2011 2012 SQL> alter table SALES drop partition SALES_2009;
  • 173. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 173 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 ...
  • 174. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 174 SQL> alter table DEMO drop partition P04; 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 P05 USABLE P06 USABLE P07 USABLE ...
  • 175. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 175 awesome for ILM
  • 176. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 176 handling old data
  • 177. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 177 2009 2010 2011 2012 SQL> alter table SALES move partition SALES_2009 2 COMPRESS;
  • 178. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 178 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
  • 179. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 179 combine with deferred segments
  • 180. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 180 2009 2010 2011 2012 SQL> alter index SALES_IX partition SALES_IX_2009 2 UNUSABLE;
  • 181. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 181 or in 12c
  • 182. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 182 2009 2010 2011 2012 SQL> alter table SALES modify partition SALES_2009 2 INDEXING OFF;
  • 183. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 183 or the opposite
  • 184. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 184 2009 2010 2011 2012 SQL> alter table SALES modify partition SALES_2012 2 INDEXING OFF; 2012
  • 185. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 185 handling new data
  • 186. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 186 2010 2011 201220132013 SQL> alter table SALES exchange 2 partition SALES_2013 with 3 table NEW_SALES;
  • 187. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | local = goodlocal = good
  • 188. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 188 global = badglobal = bad
  • 189. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 189 nope :-)
  • 190. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 190 different usage models
  • 191. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 191 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;
  • 192. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 192 or worse...
  • 193. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 193 2009 2010 2011 2012 SQL> select * 2 from SALES 3 where CUSTOMER = 123; CAR TAXI NWFB MTR CAR TAXI NWFB MTR CAR TAXI NWFB MTR CAR TAXI NWFB MTR
  • 194. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 194 explain plan
  • 195. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 195 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 | ----------------------------------------------------------------------
  • 196. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 196 2009 2010 2011 2012 SQL> select * 2 from SALES 3 where CUSTOMER = 123; 123123123123 SQL> create index SALES_IX on SALES ( CUSTOMER ) LOCAL;
  • 197. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 197 "so global for index lookups then"....
  • 198. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 198 nope :-)
  • 199. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 199 2009 2010 2011 2012 SQL> select * 2 from SALES 3 where CUSTOMER = 123 4 and YEAR = 2010; 123
  • 200. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 200 careful design
  • 201. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 201 application compromises eg unique keys
  • 202. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 202 more partitioning options
  • 203. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 203 SALES SQL> create index SALES_IX ON SALES ( CUSTOMER ) 2 global 3 partition by ....
  • 204. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 204 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 );
  • 205. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 205 rare ....
  • 206. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 206 ...one special case
  • 207. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 207 hash partitioned index
  • 208. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 208 recall: hash partitioned tables
  • 209. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 209 concurrencyASSM
  • 210. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 210 indexes a problem ascending key
  • 211. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 211
  • 212. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 212 hash partitioned indexes
  • 213. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 213 SQL> create index SALES_PK on SALES( TXN_ID ) 2 global partition by hash ( TXN_ID ) 3 partitions 8 4 / Index created.
  • 214. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 214
  • 215. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 215 Part 3 partition queries
  • 216. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 216 partition pruning
  • 217. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 217 query efficiency = data required / data scanned
  • 218. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 218 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. monthly partitions
  • 219. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 219 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. 1m rows over 360 days
  • 220. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 220 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 | ---------------------------------------------------------------
  • 221. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 221 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 | ------------------------------------------------------------
  • 222. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 222 works with binds too
  • 223. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 223 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 | ---------------------------------------------------------------
  • 224. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 224 lots of power
  • 225. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 225 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)| -----------------------------------------------------------
  • 226. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 226 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) | ---------------------------------------------------------------
  • 227. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 227 limitations of explain plan
  • 228. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 228 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
  • 229. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 229 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
  • 230. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 230 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:ORACLEDB12USERS01.DBF'
  • 231. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 231 interval partition idiosyncracy
  • 232. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 232 INTERVAL = 1 million potential partitions
  • 233. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 233 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.
  • 234. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 234 SQL> select * from DEMO; --empty ------------------------------------------------------------ | 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| ------------------------------------------------------------
  • 235. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 235 NO OP pruning
  • 236. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 236 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| --------------------------------------------------------------
  • 237. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 237 pruning composites
  • 238. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 238 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 ....
  • 239. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 239 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 | ---------------------------------------------------------------
  • 240. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 240 pruning by subquery
  • 241. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 241 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| -----------------------------------------------------------------
  • 242. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 242 huh ?
  • 243. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | bloom filters 243
  • 244. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 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 244
  • 245. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 245
  • 246. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 246 "b" bits "h" hash functions
  • 247. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 247 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 data
  • 248. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 248 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 data
  • 249. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 249 b0 b1 b2 b3 b4 b6 b7 h1 h2 h3 data b5
  • 250. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 250 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 data
  • 251. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 251 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 data
  • 252. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 252 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 matching data?
  • 253. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 253 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 matching data? do the "real" work
  • 254. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 254 b0 b1 b2 b3 b4 b5 b6 b7 h1 h2 h3 matching data?
  • 255. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 255
  • 256. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 256 metaphor
  • 257. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 257 "phone in advance"
  • 258. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 258
  • 259. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 259
  • 260. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 260 "Are you serious !? Try in 6 months"
  • 261. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 261 "There's a few seats left..."
  • 262. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 262
  • 263. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 263 false positives possible
  • 264. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 264 false negatives impossible
  • 265. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 265 other partitioning benefits
  • 266. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 266 partition wise join
  • 267. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 267 "big deal" join the partitions join the table
  • 268. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 268 our last metaphor :-)
  • 269. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 269
  • 270. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 270
  • 271. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 271 match the pairs
  • 272. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 272
  • 273. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 273
  • 274. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 274 SQL> select ... 2 from SOCKS n, SOCKS s 3 where n.STYLE_SIZE = s.STYLE_SIZE ---------------------------------------------------------------- | Id | Operation | Name | Pstart| Pstop | ---------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | |* 1 | HASH JOIN | | | | | 3 | PARTITION RANGE ALL | | 1 | 2 | | 4 | TABLE ACCESS FULL | WHITE | 1 | 2 | | 5 | PARTITION RANGE ALL | | 1 | 2 | | 6 | TABLE ACCESS FULL | BLACK | 1 | 2 | ----------------------------------------------------------------
  • 275. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 275 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 | -------------------------------------------------------------
  • 276. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | wrap up 276
  • 277. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | lots of potential ... 277
  • 278. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | benefits in many places 278
  • 279. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | "yeah but"
  • 280. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | painful to backup painful to manage painful performance probably partition
  • 281. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | the two O's "Oh crap ... we will need an Outage"
  • 282. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | partition existing table 12.2
  • 283. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 283 SQL> create table T as 2 select d.* 3 from dba_Objects d, 4 ( select 1 from dual 5 connect by level <= 20 ) 6 where d.object_id is not null; Table created. SQL> create index IX on t ( object_id ); Index created. SQL> create index IX2 on t ( created, object_name ); Index created.
  • 284. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 284 SQL> alter table T modify 2 partition by range (object_id) interval (10000) 3 ( 4 partition p1 values less than (20000) compress 5 ) online 6 including rows where created > date '2010-01-01' 7 update indexes 8 ( ix local tablespace new_idx_ts, 9 ix2 global partition by range (created) 10 ( 11 partition ix2_p1 values less than (date '2016-08-01'), 12 partition ix2_p2 values less than (maxvalue) 13 ) 14 ); Table altered.
  • 285. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | did you notice ? 285
  • 286. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 286 SQL> create table HKOUG_PRESENTATION 2 ( ... 3 ... 4 ... 5 ) 6 PARTITION BY LIST (topic) 7 ( 8 PARTITION PART1 VALUES ('TABLES'), 9 PARTITION PART2 VALUES ('INDEXES'), 10 PARTITION PART3 VALUES ('QUERIES') 11 ); 11 / Table created.
  • 287. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Thank you for your time youtube tinyurl.com/connor-tube blog connor-mcdonald.com twitter @connor_mc_d

Editor's Notes

  1. This is a Branded Title Slide with Event Look and Feel slide ideal for including a brief title, subtitle and presenter information. Do not customize this slide with your own picture. To reuse this branded background in another presentation on PC Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To reuse this branded background in another presentation on Mac Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates.
  2. This is a Branded Title Slide with Event Look and Feel slide ideal for including a brief title, subtitle and presenter information. Do not customize this slide with your own picture. To reuse this branded background in another presentation on PC Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To reuse this branded background in another presentation on Mac Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates.
  3. 14
  4. This is a Branded Title Slide with Event Look and Feel slide ideal for including a brief title, subtitle and presenter information. Do not customize this slide with your own picture. To reuse this branded background in another presentation on PC Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Reuse Slides. Click Browse in the Reuse Slides panel and select Browse Files. Double-click the PowerPoint presentation that contains the background you wish to copy. Check Keep Source Formatting and click the slide that contains the background you want. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Right-click any selected slide, point to Layout, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates. To reuse this branded background in another presentation on Mac Locate and open the presentation where you will be placing this artwork. Click New Slide from the Home tab's Slides group and select Insert Slides from Other Presentation… Navigate to the PowerPoint presentation file that contains the background you wish to copy. Double-click or press Insert. This prompts the Slide Finder dialogue box. Make sure Keep design of original slides is unchecked and click the slide(s) that contains the background you want. Hold Shift key to select multiple slides. Click the left-hand slide preview to which you wish to apply the new master layout. Apply New Layout (Important): Click Layout from the Home tab's Slides group, and click the slide containing the desired layout from the layout gallery. Delete any unwanted slides or duplicates.