SlideShare una empresa de Scribd logo
1 de 4
Descargar para leer sin conexión
12 Tips&techniques 
Franck Pachot, dbi services 
Parallel Distribution and 
12c Adaptive Plans 
In the previous newsletter we have seen how 
12c can defer the choice of the join method to the 
first execution. We considered only serial execution 
plans. But besides join method, the cardinality 
estimation is a key decision for parallel distribution 
when joining in parallel query. Ever seen a parallel 
query consuming huge tempfile space because a 
large table is broadcasted to lot of parallel proces-ses? 
This is the point addressed by Adaptive Parallel 
Distribution. 
Once again, that new feature is a good occasion 
to look at the different distribution methods. 
SOUG Newsletter 3/2014 
Parallel Query Distribution 
I’ll do the same query as in previous newsletter, joining 
EMP with DEPT, but now I choose to set a parallel degree 4 
to the EMP table. If I do the same hash join as before, DEPT 
being the built table, I will have: 
■ Four consumer processes that will do the Hash Join. 
■ One process (the coordinator) reading DEPT which is not 
in parallel – and sending rows to one of the consumer 
processes, depending on the hash value calculated from 
on the join column values. 
■ Each of the four consumers receives their part of the 
DEPT rows and hash them to create their built table. 
■ Four producer processes, each reading specific gran-ules 
of EMP, send each row to one of the four consumer. 
■ Each of the four consumers receives their part of EMP 
rows and matches them to their probe table. 
■ Each of them sends their result to the coordinator. 
Because the work was divided with a hash function on 
the join column, the final result of the join is just the 
concatenation of each consumer result. 
Here is the execution plan for that join: 
EXPLAINED SQL STATEMENT: 
------------------------ 
select * from DEPT join EMP using(deptno) 
------------------------------------------------------------------------------------------------------------------ 
| Id | Operation | Name | Starts | TQ | IN-OUT| PQ Distrib | A-Rows | Buffers | OMem | 
------------------------------------------------------------------------------------------------------------------ 
| 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | 
| 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | 
| 2 | PX SEND QC (RANDOM) | :TQ10002 | 0 | Q1,02 | P->S | QC (RAND) | 0 | 0 | | 
|* 3 | HASH JOIN BUFFERED | | 4 | Q1,02 | PCWP | | 14 | 0 | 1542K | 
| 4 | BUFFER SORT | | 4 | Q1,02 | PCWC | | 4 | 0 | 2048 | 
| 5 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 4 | 0 | | 
| 6 | PX SEND HASH | :TQ10000 | 0 | | S->P | HASH | 0 | 0 | | 
| 7 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | 
| 8 | PX RECEIVE | | 3 | Q1,02 | PCWP | | 14 | 0 | | 
| 9 | PX SEND HASH | :TQ10001 | 0 | Q1,01 | P->P | HASH | 0 | 0 | | 
| 10 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | 
|* 11 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | 
------------------------------------------------------------------------------------------------------------------ 
Execution Plan 1: PX hash distribution 
The Q1,01 is the producer set that reads EMP, the Q1,02 
is the consumer set that does the join. The ’PQ Distrib’ 
column shows the HASH distribution for both the outer 
rowsource DEPT and the inner table EMP. The hint for 
that is PQ_DISTRIBUTE(DEPT HASH HASH) to be added 
to the leading(EMP DEPT) use_hash(DEPT) swap_join_ 
inputs(DEPT) that defines the join order and method. 
This is efficient when both tables are big. But with a DOP 
of 4 we have 1+2*4=8 processes and a lot of messaging 
among them.
Tips&ceehinqstu 13 
SOUG Newsletter 3/2014 
When one table is not so big, then we can avoid a whole 
set of parallel processes. We can broadcast the small table 
(DEPT) to the 4 parallel processes doing the join. In that case, 
the same set of processes is able to read EMP and do the 
join. 
Here is the execution plan: 
EXPLAINED SQL STATEMENT: 
------------------------ 
select /*+ leading(EMP DEPT) use_hash(DEPT) swap_join_inputs(DEPT) pq_distribute(DEPT NONE BROADCAST) */ * from 
DEPT join EMP using(deptno) 
--------------------------------------------------------------------------------------------------------------- 
| Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | 
--------------------------------------------------------------------------------------------------------------- 
| 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | 
| 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | 
| 2 | PX SEND QC (RANDOM) | :TQ10001 | 0 | Q1,01 | P->S | QC (RAND) | 0 | 0 | | 
|* 3 | HASH JOIN | | 4 | Q1,01 | PCWP | | 14 | 15 | 1321K| 
| 4 | BUFFER SORT | | 4 | Q1,01 | PCWC | | 16 | 0 | 2048 | 
| 5 | PX RECEIVE | | 4 | Q1,01 | PCWP | | 16 | 0 | | 
| 6 | PX SEND BROADCAST | :TQ10000 | 0 | | S->P | BROADCAST | 0 | 0 | | 
| 7 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | 
| 8 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | 
|* 9 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | 
------------------------------------------------------------------------------------------------------------------ 
Execution Plan 2: PX broadcast from serial 
The coordinator reads DEPT and broadcasts all rows to 
each parallel server process (Q1,01). Those processes build 
the hash table for DEPT and then read their granules of EMP. 
With the PQ_DISTRIBUTE we can choose how to distrib-ute 
a table to the consumer that will process the rows. The 
syntax is PQ_DISTRIBUTE(inner_table outer_distribution in-ner_ 
distribution). For HASH we must use the same hash 
function, so we will see PQ_DISTRIBUTE(DEPT HASH HASH) 
for producers sending to consumer according to the hash 
function. 
We can choose to broadcast the inner table with 
PQ_DISTRIBUTE(DEPT NONE BROADCAST) or the outer 
rowsource PQ_DISTRIBUTE(DEPT BROADCAST NONE). 
The broadcasted table will be received in a whole by each 
consumer, so it can take a lot of memory, when it is buffered 
by the join operation and when the DOP is high. 
When the tables are partitioned, the consumers can 
divide their job by partitions instead of granules, and we 
can distribute rows that match each consumer partition. For 
example, if EMP is partitioned on DEPTNO, then PQ_ 
DISTRIBUTE(DEPT NONE PARTITION) will distribute the 
DEPT rows to the right consumer process according 
to DEPTNO value. The opposite PQ_DISTRIBUTE (DEPT 
PARTITION NONE) would be done, if DEPT were partitioned 
on DEPTNO. 
And if both EMP and DEPT are partitioned on DEPTNO, 
then there is nothing to distribute: PQ_DISTRIBUTE(DEPT 
NONE NONE) because each parallel process is able to read 
both EMP and DEPT partition and do the Hash Join. This is 
known as partition-wise join and is very efficient when the 
number of partition is equal to the DOP, or a large multiple.
14 Tips&techniques 
12c Small Table Replicate 
If we take the example above where DEPT was broad-casted, 
but setting a parallel degree on DEPT as well, we 
have the following execution plan: 
--------------------------------------------------------------------------------------------------------------- 
| Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | 
--------------------------------------------------------------------------------------------------------------- 
| 0 | SELECT STATEMENT | | 1 | | | | 14 | 6 | | 
| 1 | PX COORDINATOR | | 1 | | | | 14 | 6 | | 
| 2 | PX SEND QC (RANDOM) | :TQ10001 | 0 | Q1,01 | P->S | QC (RAND) | 0 | 0 | | 
|* 3 | HASH JOIN | | 4 | Q1,01 | PCWP | | 14 | 15 | 1321K| 
| 4 | PX RECEIVE | | 4 | Q1,01 | PCWP | | 16 | 0 | | 
| 5 | PX SEND BROADCAST | :TQ10000 | 0 | Q1,00 | P->P | BROADCAST | 0 | 0 | | 
| 6 | PX BLOCK ITERATOR | | 4 | Q1,00 | PCWC | | 4 | 15 | | 
|* 7 | TABLE ACCESS FULL | DEPT | 5 | Q1,00 | PCWP | | 4 | 15 | | 
| 8 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | 
|* 9 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | 
--------------------------------------------------------------------------------------------------------------- 
Execution Plan 3: PX broadcast from parallel 
Here we have a set of producers (Q1,00) that will broad-cast 
to all consumers (Q1,01). That was the behavior in 11g. 
In 12c a step further than broadcasting can be done by 
replicating the reading of DEPT in all consumers instead of 
broadcasting. 
--------------------------------------------------------------------------------------------------------------- 
| Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | 
--------------------------------------------------------------------------------------------------------------- 
| 0 | SELECT STATEMENT | | 1 | | | | 14 | 3 | | 
| 1 | PX COORDINATOR | | 1 | | | | 14 | 3 | | 
| 2 | PX SEND QC (RANDOM) | :TQ10000 | 0 | Q1,00 | P->S | QC (RAND) | 0 | 0 | | 
|* 3 | HASH JOIN | | 4 | Q1,00 | PCWP | | 14 | 43 | 1321K | 
| 4 | TABLE ACCESS FULL | DEPT | 4 | Q1,00 | PCWP | | 16 | 28 | | 
| 5 | PX BLOCK ITERATOR | | 4 | Q1,00 | PCWC | | 14 | 15 | | 
|* 6 | TABLE ACCESS FULL | EMP | 5 | Q1,00 | PCWP | | 14 | 15 | | 
--------------------------------------------------------------------------------------------------------------- 
Execution Plan 4: PQ replicate 
That optimization requires more I/O (but it concerns only 
small tables anyway – in can be cached when using In-Mem-ory 
parallel execution) but saves processes, memory and 
messaging. The hint is PQ_DISTRIBUTE(DEPT NONE 
BROADCAST) PQ_REPLICATE(DEPT) 
SOUG Newsletter 3/2014 
12c Adaptive Parallel 
Distribution 
12c comes with Adaptive Plans. We have seen in the pre-vious 
newsletter the Adaptive Join when it is difficult to esti-mate 
the cardinality and to choose between Nested Loop 
and Hash Join. It is the same concern here when choosing 
between broadcast and hash distribution: Adaptive Parallel 
Distribution. 
The previous HASH HASH parallel plans were done in 
11g. Here is the same in 12c: 
EXPLAINED SQL STATEMENT: 
------------------------ 
select * from DEPT join EMP using(deptno) 
--------------------------------------------------------------------------------------------------------------- 
| Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | 
--------------------------------------------------------------------------------------------------------------- 
| 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | 
| 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | 
| 2 | PX SEND QC (RANDOM) | :TQ10002 | 0 | Q1,02 | P->S | QC (RAND) | 0 | 0 | | 
|* 3 | HASH JOIN BUFFERED | | 4 | Q1,02 | PCWP | | 14 | 0 | 1542K | 
| 4 | BUFFER SORT | | 4 | Q1,02 | PCWC | | 16 | 0 | 2048 | 
| 5 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 16 | 0 | | 
| 6 | PX SEND HYBRID HASH | :TQ10000 | 0 | | S->P | HYBRID HASH | 0 | 0 | | 
| 7 | STATISTICS COLLECTOR | | 1 | | | | 4 | 7 | | 
| 8 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | 
| 9 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 14 | 0 | | 
| 10 | PX SEND HYBRID HASH | :TQ10001 | 0 | Q1,01 | P->P | HYBRID HASH | 0 | 0 | | 
| 11 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | 
|* 12 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | 
Execution Plan 5: Adaptive Parallel Distribution
Tips&ceehinqstu 15 
SOUG Newsletter 3/2014 
The distribution is HYBRID HASH and there is a STATIS-TICS 
COLLECTOR before sending to parallel server consu­mers. 
Oracle will count the rows coming from DEPT and will 
choose to BROADCAST or HASH depending on the number 
of rows. 
It is easy to check what has been chosen here, knowing 
that the DOP was 4. I have 4 rows coming from DEPT 
(’A-rows’ on DEPT TABLE ACCESS FULL) and 16 were re-ceived 
by the consumer (’A-Rows’ on PX RECEIVE): this is 
broadcast (4x4=16). 
Parallel Query Distribution from 
SQL Monitoring 
When we have the Tuning Pack, it is easier to get execu-tion 
statistics from SQL Monitoring. Here are the same exe-cution 
plans as above, but gathered with SQL Monitoring re-ports. 
The coordinator in green does everything that is done in 
serial. The producers are in blue, the consumers are in red. 
Here is the Hash distribution where DEPT read in serial 
and EMP read in parallel are both distributed to the right con-sumer 
that does the join: 
SQL Monitor 1: PX hash distribution 
Here is the broadcast from DEPT serial read: 
SQL Monitor 2: PX broadcast from serial 
And the broadcast from DEPT parallel read (two sets of 
parallel servers): 
SQL Monitor 3: PX broadcast from parallel 
Then here is the 12c Small Table Replicate allowing to 
read DEPT from the same set of parallel processes that is 
doing the join: 
SQL Monitor 4: PQ replicate 
And in 12c, the choice between HASH and BROADCAST 
being done at runtime, and called HYBRID HASH: 
SQL Monitor 5: Adaptive Parallel Distribution 
Conclusion 
Long before MapReduce became a buzzword, Oracle 
was able to distribute the processing of SQL queries to sev-eral 
parallel processes (and to several nodes when in RAC). 
Reading a table in parallel is easy: Each process reads a sep-arate 
chunk. But when we need to join tables, then the rows 
have to be distributed from a set of producers (which full scan 
their chunks) to a set of consumers (which will do the join). 
Small row sets do not need to be processed in parallel and 
can be broadcasted to each consumer. But large rowset will 
be distributed to the right process only. The choice depends 
on the size and then the Cost Based Optimizer estimation of 
cardinality is a key point. 
As we have seen for join methods, Oracle 12c can defer 
that choice to the first execution. This is Adaptive Parallel 
Distribution. ■ 
Contact 
dbi services 
Franck Pachot 
E-Mail: 
franck.pachot@dbi-services.com

Más contenido relacionado

La actualidad más candente

Oracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture PerformanceOracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture Performance
Enkitec
 

La actualidad más candente (20)

Oracle Database performance tuning using oratop
Oracle Database performance tuning using oratopOracle Database performance tuning using oratop
Oracle Database performance tuning using oratop
 
Same plan different performance
Same plan different performanceSame plan different performance
Same plan different performance
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
 
Oracle Performance Tuning Fundamentals
Oracle Performance Tuning FundamentalsOracle Performance Tuning Fundamentals
Oracle Performance Tuning Fundamentals
 
In-memory OLTP storage with persistence and transaction support
In-memory OLTP storage with persistence and transaction supportIn-memory OLTP storage with persistence and transaction support
In-memory OLTP storage with persistence and transaction support
 
TFA Collector - what can one do with it
TFA Collector - what can one do with it TFA Collector - what can one do with it
TFA Collector - what can one do with it
 
Oracle RAC features on Exadata
Oracle RAC features on ExadataOracle RAC features on Exadata
Oracle RAC features on Exadata
 
OLTP+OLAP=HTAP
 OLTP+OLAP=HTAP OLTP+OLAP=HTAP
OLTP+OLAP=HTAP
 
Standard Edition High Availability (SEHA) - The Why, What & How
Standard Edition High Availability (SEHA) - The Why, What & HowStandard Edition High Availability (SEHA) - The Why, What & How
Standard Edition High Availability (SEHA) - The Why, What & How
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
Oracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture PerformanceOracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture Performance
 
Why Use an Oracle Database?
Why Use an Oracle Database?Why Use an Oracle Database?
Why Use an Oracle Database?
 
Why oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19cWhy oracle data guard new features in oracle 18c, 19c
Why oracle data guard new features in oracle 18c, 19c
 
Oracle Performance Tools of the Trade
Oracle Performance Tools of the TradeOracle Performance Tools of the Trade
Oracle Performance Tools of the Trade
 
Under the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database ArchitectureUnder the Hood of a Shard-per-Core Database Architecture
Under the Hood of a Shard-per-Core Database Architecture
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Hadoop Backup and Disaster Recovery
Hadoop Backup and Disaster RecoveryHadoop Backup and Disaster Recovery
Hadoop Backup and Disaster Recovery
 
Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014Ash architecture and advanced usage rmoug2014
Ash architecture and advanced usage rmoug2014
 
Battle of the Stream Processing Titans – Flink versus RisingWave
Battle of the Stream Processing Titans – Flink versus RisingWaveBattle of the Stream Processing Titans – Flink versus RisingWave
Battle of the Stream Processing Titans – Flink versus RisingWave
 
Advanced RAC troubleshooting: Network
Advanced RAC troubleshooting: NetworkAdvanced RAC troubleshooting: Network
Advanced RAC troubleshooting: Network
 

Destacado

English introduction
English introductionEnglish introduction
English introduction
gabriela
 
Multicultural Week
Multicultural WeekMulticultural Week
Multicultural Week
gabriela
 
Visual Essay Eci205
Visual Essay Eci205Visual Essay Eci205
Visual Essay Eci205
kmfidish
 
Itunes vs rhapsody
Itunes vs rhapsodyItunes vs rhapsody
Itunes vs rhapsody
cmcsoley458
 
Le cerveau humain
Le cerveau humainLe cerveau humain
Le cerveau humain
Jay Ben
 
Aplikacija "Kas vyks
Aplikacija "Kas vyksAplikacija "Kas vyks
Aplikacija "Kas vyks
PDFONTOUR
 
Magazine advertisement questionnaire advert one
Magazine advertisement questionnaire   advert oneMagazine advertisement questionnaire   advert one
Magazine advertisement questionnaire advert one
ChrisAshwell
 
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
somdetpittayakom school
 

Destacado (20)

Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory optionStar Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
Star Transformation, 12c Adaptive Bitmap Pruning and In-Memory option
 
Oracle Join Methods and 12c Adaptive Plans
Oracle Join Methods and 12c Adaptive PlansOracle Join Methods and 12c Adaptive Plans
Oracle Join Methods and 12c Adaptive Plans
 
English introduction
English introductionEnglish introduction
English introduction
 
Multicultural Week
Multicultural WeekMulticultural Week
Multicultural Week
 
Visual Essay Eci205
Visual Essay Eci205Visual Essay Eci205
Visual Essay Eci205
 
Itunes vs rhapsody
Itunes vs rhapsodyItunes vs rhapsody
Itunes vs rhapsody
 
Nutro: Owner vs. Dog
Nutro: Owner vs. DogNutro: Owner vs. Dog
Nutro: Owner vs. Dog
 
Frost & Sullivan Smart Buildings Think Tank Cr
Frost & Sullivan   Smart Buildings Think Tank CrFrost & Sullivan   Smart Buildings Think Tank Cr
Frost & Sullivan Smart Buildings Think Tank Cr
 
Modul gangguan seksualitas
Modul gangguan seksualitasModul gangguan seksualitas
Modul gangguan seksualitas
 
Choinka 323
Choinka 323Choinka 323
Choinka 323
 
Pengantar gerontologi semester s1
Pengantar gerontologi semester s1Pengantar gerontologi semester s1
Pengantar gerontologi semester s1
 
Introduction to derivatives
Introduction to derivatives Introduction to derivatives
Introduction to derivatives
 
Moving Forward by Looking Backward
Moving Forward by Looking BackwardMoving Forward by Looking Backward
Moving Forward by Looking Backward
 
Le cerveau humain
Le cerveau humainLe cerveau humain
Le cerveau humain
 
Aplikacija "Kas vyks
Aplikacija "Kas vyksAplikacija "Kas vyks
Aplikacija "Kas vyks
 
Tatabahasatahun6
Tatabahasatahun6Tatabahasatahun6
Tatabahasatahun6
 
Magazine advertisement questionnaire advert one
Magazine advertisement questionnaire   advert oneMagazine advertisement questionnaire   advert one
Magazine advertisement questionnaire advert one
 
หน่วยที่ 6
หน่วยที่ 6หน่วยที่ 6
หน่วยที่ 6
 
บทที่ 8 เสียง
บทที่ 8 เสียงบทที่ 8 เสียง
บทที่ 8 เสียง
 
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
คำอธิบายรายวิชาและจุดประสงค์การเรียนรู้ ม.5
 

Similar a Oracle Parallel Distribution and 12c Adaptive Plans

Adaptive Query Optimization in 12c
Adaptive Query Optimization in 12cAdaptive Query Optimization in 12c
Adaptive Query Optimization in 12c
Anju Garg
 
Sydney Oracle Meetup - access paths
Sydney Oracle Meetup - access pathsSydney Oracle Meetup - access paths
Sydney Oracle Meetup - access paths
paulguerin
 
22220161• General Purpose Simulation System (IBM - 1.docx
22220161• General Purpose Simulation System (IBM - 1.docx22220161• General Purpose Simulation System (IBM - 1.docx
22220161• General Purpose Simulation System (IBM - 1.docx
tamicawaysmith
 
2010 03 papi_indiana
2010 03 papi_indiana2010 03 papi_indiana
2010 03 papi_indiana
PTIHPA
 

Similar a Oracle Parallel Distribution and 12c Adaptive Plans (20)

Hash joins and bloom filters at AMIS25
Hash joins and bloom filters at AMIS25Hash joins and bloom filters at AMIS25
Hash joins and bloom filters at AMIS25
 
Analysing and troubleshooting Parallel Execution IT Tage 2015
Analysing and troubleshooting Parallel Execution IT Tage 2015Analysing and troubleshooting Parallel Execution IT Tage 2015
Analysing and troubleshooting Parallel Execution IT Tage 2015
 
Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...
Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...
Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...
 
Parallel Execution With Oracle Database 12c - Masterclass
Parallel Execution With Oracle Database 12c - MasterclassParallel Execution With Oracle Database 12c - Masterclass
Parallel Execution With Oracle Database 12c - Masterclass
 
Subquery factoring for FTS
Subquery factoring for FTSSubquery factoring for FTS
Subquery factoring for FTS
 
Adaptive Query Optimization in 12c
Adaptive Query Optimization in 12cAdaptive Query Optimization in 12c
Adaptive Query Optimization in 12c
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 
Sydney Oracle Meetup - access paths
Sydney Oracle Meetup - access pathsSydney Oracle Meetup - access paths
Sydney Oracle Meetup - access paths
 
OracleDatabase12cPXNewFeatures_ITOUG_2018.pdf
OracleDatabase12cPXNewFeatures_ITOUG_2018.pdfOracleDatabase12cPXNewFeatures_ITOUG_2018.pdf
OracleDatabase12cPXNewFeatures_ITOUG_2018.pdf
 
PoC Oracle Exadata - Retour d'expérience
PoC Oracle Exadata - Retour d'expériencePoC Oracle Exadata - Retour d'expérience
PoC Oracle Exadata - Retour d'expérience
 
Do You Know The 11g Plan?
Do You Know The 11g Plan?Do You Know The 11g Plan?
Do You Know The 11g Plan?
 
Px execution in rac
Px execution in racPx execution in rac
Px execution in rac
 
22220161• General Purpose Simulation System (IBM - 1.docx
22220161• General Purpose Simulation System (IBM - 1.docx22220161• General Purpose Simulation System (IBM - 1.docx
22220161• General Purpose Simulation System (IBM - 1.docx
 
2010 03 papi_indiana
2010 03 papi_indiana2010 03 papi_indiana
2010 03 papi_indiana
 
Q series brochure_2008-03
Q series brochure_2008-03Q series brochure_2008-03
Q series brochure_2008-03
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
 
Adaptive Query Optimization
Adaptive Query OptimizationAdaptive Query Optimization
Adaptive Query Optimization
 
Rip and OSPF assignment (RIP ба OSPF дасгал ажил)
Rip and OSPF assignment (RIP ба OSPF дасгал ажил)Rip and OSPF assignment (RIP ба OSPF дасгал ажил)
Rip and OSPF assignment (RIP ба OSPF дасгал ажил)
 
Pipelining And Vector Processing
Pipelining And Vector ProcessingPipelining And Vector Processing
Pipelining And Vector Processing
 

Más de Franck Pachot

Más de Franck Pachot (15)

Meetup - YugabyteDB - Introduction and key features
Meetup - YugabyteDB - Introduction and key featuresMeetup - YugabyteDB - Introduction and key features
Meetup - YugabyteDB - Introduction and key features
 
Oracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor formatOracle dbms_xplan.display_cursor format
Oracle dbms_xplan.display_cursor format
 
19 features you will miss if you leave Oracle Database
19 features you will miss if you leave Oracle Database19 features you will miss if you leave Oracle Database
19 features you will miss if you leave Oracle Database
 
Oracle Database on Docker
Oracle Database on DockerOracle Database on Docker
Oracle Database on Docker
 
12cR2 Single-Tenant: Multitenant Features for All Editions
12cR2 Single-Tenant: Multitenant Features for All Editions12cR2 Single-Tenant: Multitenant Features for All Editions
12cR2 Single-Tenant: Multitenant Features for All Editions
 
Les bases BI sont-elles différentes?
Les bases BI sont-elles différentes?Les bases BI sont-elles différentes?
Les bases BI sont-elles différentes?
 
Oracle in-Memory Column Store for BI
Oracle in-Memory Column Store for BIOracle in-Memory Column Store for BI
Oracle in-Memory Column Store for BI
 
Testing Delphix: easy data virtualization
Testing Delphix: easy data virtualizationTesting Delphix: easy data virtualization
Testing Delphix: easy data virtualization
 
12c SQL Plan Directives
12c SQL Plan Directives12c SQL Plan Directives
12c SQL Plan Directives
 
CBO choice between Index and Full Scan: the good, the bad and the ugly param...
CBO choice between Index and Full Scan:  the good, the bad and the ugly param...CBO choice between Index and Full Scan:  the good, the bad and the ugly param...
CBO choice between Index and Full Scan: the good, the bad and the ugly param...
 
Oracle NOLOGGING
Oracle NOLOGGINGOracle NOLOGGING
Oracle NOLOGGING
 
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
Exadata X3 in action:  Measuring Smart Scan efficiency with AWRExadata X3 in action:  Measuring Smart Scan efficiency with AWR
Exadata X3 in action: Measuring Smart Scan efficiency with AWR
 
Oracle table lock modes
Oracle table lock modesOracle table lock modes
Oracle table lock modes
 
Dbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easyDbvisit replicate: logical replication made easy
Dbvisit replicate: logical replication made easy
 
Reading AWR or Statspack Report - Straight to the Goal
Reading AWR or Statspack Report - Straight to the GoalReading AWR or Statspack Report - Straight to the Goal
Reading AWR or Statspack Report - Straight to the Goal
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Oracle Parallel Distribution and 12c Adaptive Plans

  • 1. 12 Tips&techniques Franck Pachot, dbi services Parallel Distribution and 12c Adaptive Plans In the previous newsletter we have seen how 12c can defer the choice of the join method to the first execution. We considered only serial execution plans. But besides join method, the cardinality estimation is a key decision for parallel distribution when joining in parallel query. Ever seen a parallel query consuming huge tempfile space because a large table is broadcasted to lot of parallel proces-ses? This is the point addressed by Adaptive Parallel Distribution. Once again, that new feature is a good occasion to look at the different distribution methods. SOUG Newsletter 3/2014 Parallel Query Distribution I’ll do the same query as in previous newsletter, joining EMP with DEPT, but now I choose to set a parallel degree 4 to the EMP table. If I do the same hash join as before, DEPT being the built table, I will have: ■ Four consumer processes that will do the Hash Join. ■ One process (the coordinator) reading DEPT which is not in parallel – and sending rows to one of the consumer processes, depending on the hash value calculated from on the join column values. ■ Each of the four consumers receives their part of the DEPT rows and hash them to create their built table. ■ Four producer processes, each reading specific gran-ules of EMP, send each row to one of the four consumer. ■ Each of the four consumers receives their part of EMP rows and matches them to their probe table. ■ Each of them sends their result to the coordinator. Because the work was divided with a hash function on the join column, the final result of the join is just the concatenation of each consumer result. Here is the execution plan for that join: EXPLAINED SQL STATEMENT: ------------------------ select * from DEPT join EMP using(deptno) ------------------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Starts | TQ | IN-OUT| PQ Distrib | A-Rows | Buffers | OMem | ------------------------------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | | 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | 0 | Q1,02 | P->S | QC (RAND) | 0 | 0 | | |* 3 | HASH JOIN BUFFERED | | 4 | Q1,02 | PCWP | | 14 | 0 | 1542K | | 4 | BUFFER SORT | | 4 | Q1,02 | PCWC | | 4 | 0 | 2048 | | 5 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 4 | 0 | | | 6 | PX SEND HASH | :TQ10000 | 0 | | S->P | HASH | 0 | 0 | | | 7 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | | 8 | PX RECEIVE | | 3 | Q1,02 | PCWP | | 14 | 0 | | | 9 | PX SEND HASH | :TQ10001 | 0 | Q1,01 | P->P | HASH | 0 | 0 | | | 10 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | |* 11 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | ------------------------------------------------------------------------------------------------------------------ Execution Plan 1: PX hash distribution The Q1,01 is the producer set that reads EMP, the Q1,02 is the consumer set that does the join. The ’PQ Distrib’ column shows the HASH distribution for both the outer rowsource DEPT and the inner table EMP. The hint for that is PQ_DISTRIBUTE(DEPT HASH HASH) to be added to the leading(EMP DEPT) use_hash(DEPT) swap_join_ inputs(DEPT) that defines the join order and method. This is efficient when both tables are big. But with a DOP of 4 we have 1+2*4=8 processes and a lot of messaging among them.
  • 2. Tips&ceehinqstu 13 SOUG Newsletter 3/2014 When one table is not so big, then we can avoid a whole set of parallel processes. We can broadcast the small table (DEPT) to the 4 parallel processes doing the join. In that case, the same set of processes is able to read EMP and do the join. Here is the execution plan: EXPLAINED SQL STATEMENT: ------------------------ select /*+ leading(EMP DEPT) use_hash(DEPT) swap_join_inputs(DEPT) pq_distribute(DEPT NONE BROADCAST) */ * from DEPT join EMP using(deptno) --------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | --------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | | 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | | 2 | PX SEND QC (RANDOM) | :TQ10001 | 0 | Q1,01 | P->S | QC (RAND) | 0 | 0 | | |* 3 | HASH JOIN | | 4 | Q1,01 | PCWP | | 14 | 15 | 1321K| | 4 | BUFFER SORT | | 4 | Q1,01 | PCWC | | 16 | 0 | 2048 | | 5 | PX RECEIVE | | 4 | Q1,01 | PCWP | | 16 | 0 | | | 6 | PX SEND BROADCAST | :TQ10000 | 0 | | S->P | BROADCAST | 0 | 0 | | | 7 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | | 8 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | |* 9 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | ------------------------------------------------------------------------------------------------------------------ Execution Plan 2: PX broadcast from serial The coordinator reads DEPT and broadcasts all rows to each parallel server process (Q1,01). Those processes build the hash table for DEPT and then read their granules of EMP. With the PQ_DISTRIBUTE we can choose how to distrib-ute a table to the consumer that will process the rows. The syntax is PQ_DISTRIBUTE(inner_table outer_distribution in-ner_ distribution). For HASH we must use the same hash function, so we will see PQ_DISTRIBUTE(DEPT HASH HASH) for producers sending to consumer according to the hash function. We can choose to broadcast the inner table with PQ_DISTRIBUTE(DEPT NONE BROADCAST) or the outer rowsource PQ_DISTRIBUTE(DEPT BROADCAST NONE). The broadcasted table will be received in a whole by each consumer, so it can take a lot of memory, when it is buffered by the join operation and when the DOP is high. When the tables are partitioned, the consumers can divide their job by partitions instead of granules, and we can distribute rows that match each consumer partition. For example, if EMP is partitioned on DEPTNO, then PQ_ DISTRIBUTE(DEPT NONE PARTITION) will distribute the DEPT rows to the right consumer process according to DEPTNO value. The opposite PQ_DISTRIBUTE (DEPT PARTITION NONE) would be done, if DEPT were partitioned on DEPTNO. And if both EMP and DEPT are partitioned on DEPTNO, then there is nothing to distribute: PQ_DISTRIBUTE(DEPT NONE NONE) because each parallel process is able to read both EMP and DEPT partition and do the Hash Join. This is known as partition-wise join and is very efficient when the number of partition is equal to the DOP, or a large multiple.
  • 3. 14 Tips&techniques 12c Small Table Replicate If we take the example above where DEPT was broad-casted, but setting a parallel degree on DEPT as well, we have the following execution plan: --------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | --------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | | 14 | 6 | | | 1 | PX COORDINATOR | | 1 | | | | 14 | 6 | | | 2 | PX SEND QC (RANDOM) | :TQ10001 | 0 | Q1,01 | P->S | QC (RAND) | 0 | 0 | | |* 3 | HASH JOIN | | 4 | Q1,01 | PCWP | | 14 | 15 | 1321K| | 4 | PX RECEIVE | | 4 | Q1,01 | PCWP | | 16 | 0 | | | 5 | PX SEND BROADCAST | :TQ10000 | 0 | Q1,00 | P->P | BROADCAST | 0 | 0 | | | 6 | PX BLOCK ITERATOR | | 4 | Q1,00 | PCWC | | 4 | 15 | | |* 7 | TABLE ACCESS FULL | DEPT | 5 | Q1,00 | PCWP | | 4 | 15 | | | 8 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | |* 9 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | --------------------------------------------------------------------------------------------------------------- Execution Plan 3: PX broadcast from parallel Here we have a set of producers (Q1,00) that will broad-cast to all consumers (Q1,01). That was the behavior in 11g. In 12c a step further than broadcasting can be done by replicating the reading of DEPT in all consumers instead of broadcasting. --------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | --------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | | 14 | 3 | | | 1 | PX COORDINATOR | | 1 | | | | 14 | 3 | | | 2 | PX SEND QC (RANDOM) | :TQ10000 | 0 | Q1,00 | P->S | QC (RAND) | 0 | 0 | | |* 3 | HASH JOIN | | 4 | Q1,00 | PCWP | | 14 | 43 | 1321K | | 4 | TABLE ACCESS FULL | DEPT | 4 | Q1,00 | PCWP | | 16 | 28 | | | 5 | PX BLOCK ITERATOR | | 4 | Q1,00 | PCWC | | 14 | 15 | | |* 6 | TABLE ACCESS FULL | EMP | 5 | Q1,00 | PCWP | | 14 | 15 | | --------------------------------------------------------------------------------------------------------------- Execution Plan 4: PQ replicate That optimization requires more I/O (but it concerns only small tables anyway – in can be cached when using In-Mem-ory parallel execution) but saves processes, memory and messaging. The hint is PQ_DISTRIBUTE(DEPT NONE BROADCAST) PQ_REPLICATE(DEPT) SOUG Newsletter 3/2014 12c Adaptive Parallel Distribution 12c comes with Adaptive Plans. We have seen in the pre-vious newsletter the Adaptive Join when it is difficult to esti-mate the cardinality and to choose between Nested Loop and Hash Join. It is the same concern here when choosing between broadcast and hash distribution: Adaptive Parallel Distribution. The previous HASH HASH parallel plans were done in 11g. Here is the same in 12c: EXPLAINED SQL STATEMENT: ------------------------ select * from DEPT join EMP using(deptno) --------------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | TQ | IN-OUT | PQ Distrib | A-Rows | Buffers | OMem | --------------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | | | 14 | 10 | | | 1 | PX COORDINATOR | | 1 | | | | 14 | 10 | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | 0 | Q1,02 | P->S | QC (RAND) | 0 | 0 | | |* 3 | HASH JOIN BUFFERED | | 4 | Q1,02 | PCWP | | 14 | 0 | 1542K | | 4 | BUFFER SORT | | 4 | Q1,02 | PCWC | | 16 | 0 | 2048 | | 5 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 16 | 0 | | | 6 | PX SEND HYBRID HASH | :TQ10000 | 0 | | S->P | HYBRID HASH | 0 | 0 | | | 7 | STATISTICS COLLECTOR | | 1 | | | | 4 | 7 | | | 8 | TABLE ACCESS FULL | DEPT | 1 | | | | 4 | 7 | | | 9 | PX RECEIVE | | 4 | Q1,02 | PCWP | | 14 | 0 | | | 10 | PX SEND HYBRID HASH | :TQ10001 | 0 | Q1,01 | P->P | HYBRID HASH | 0 | 0 | | | 11 | PX BLOCK ITERATOR | | 4 | Q1,01 | PCWC | | 14 | 15 | | |* 12 | TABLE ACCESS FULL | EMP | 5 | Q1,01 | PCWP | | 14 | 15 | | Execution Plan 5: Adaptive Parallel Distribution
  • 4. Tips&ceehinqstu 15 SOUG Newsletter 3/2014 The distribution is HYBRID HASH and there is a STATIS-TICS COLLECTOR before sending to parallel server consu­mers. Oracle will count the rows coming from DEPT and will choose to BROADCAST or HASH depending on the number of rows. It is easy to check what has been chosen here, knowing that the DOP was 4. I have 4 rows coming from DEPT (’A-rows’ on DEPT TABLE ACCESS FULL) and 16 were re-ceived by the consumer (’A-Rows’ on PX RECEIVE): this is broadcast (4x4=16). Parallel Query Distribution from SQL Monitoring When we have the Tuning Pack, it is easier to get execu-tion statistics from SQL Monitoring. Here are the same exe-cution plans as above, but gathered with SQL Monitoring re-ports. The coordinator in green does everything that is done in serial. The producers are in blue, the consumers are in red. Here is the Hash distribution where DEPT read in serial and EMP read in parallel are both distributed to the right con-sumer that does the join: SQL Monitor 1: PX hash distribution Here is the broadcast from DEPT serial read: SQL Monitor 2: PX broadcast from serial And the broadcast from DEPT parallel read (two sets of parallel servers): SQL Monitor 3: PX broadcast from parallel Then here is the 12c Small Table Replicate allowing to read DEPT from the same set of parallel processes that is doing the join: SQL Monitor 4: PQ replicate And in 12c, the choice between HASH and BROADCAST being done at runtime, and called HYBRID HASH: SQL Monitor 5: Adaptive Parallel Distribution Conclusion Long before MapReduce became a buzzword, Oracle was able to distribute the processing of SQL queries to sev-eral parallel processes (and to several nodes when in RAC). Reading a table in parallel is easy: Each process reads a sep-arate chunk. But when we need to join tables, then the rows have to be distributed from a set of producers (which full scan their chunks) to a set of consumers (which will do the join). Small row sets do not need to be processed in parallel and can be broadcasted to each consumer. But large rowset will be distributed to the right process only. The choice depends on the size and then the Cost Based Optimizer estimation of cardinality is a key point. As we have seen for join methods, Oracle 12c can defer that choice to the first execution. This is Adaptive Parallel Distribution. ■ Contact dbi services Franck Pachot E-Mail: franck.pachot@dbi-services.com