SlideShare a Scribd company logo
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filters
Toon Koppelaars
Real World Performance team
Database Server Technologies
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash function
Hash joins
Bloom filters
Agenda
Examples
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash joins and Bloom filters
• Bloom filters (BF) introduced in 10gR2
– Enable CBO to “filter early” in hash joins
– Used automatically, visible in execution plan
• Implemented to speed up large parallel hash joins (DWH/BI)
– BF’s prevent unnecessary row-transport between parallel query slave sets
• As of 11.2.0.4 BF’s may also show up in serial plans
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash joins explained
-----------------------------------
| Id | Operation | Name |
-----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | HASH JOIN | |
| 2 | TABLE ACCESS FULL| DEPT |
| 3 | TABLE ACCESS FULL| EMP |
-----------------------------------
Predicate Information
---------------------------------------
1 - access("D"."DEPTNO"="E"."DEPTNO")
select *
from emp e, dept d
where d.deptno = e.deptno
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
What is a hash-function?
– Hash function application is cheap
– Hash values are typically “evenly
distributed” in range
• Irrespective of distribution of input values
– Collisions can occur
• Two domain values map to same hash value
• Since #domain >> #range
Domain Range
Hash
function
Digital data
Byte strings of any length
“Hash values”
Offset between
[0..some-power-of-2 minus 1]
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Phase 1: build hash table (DEPT)
-----------------------------------
| Id | Operation | Name |
-----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | HASH JOIN | |
| 2 | TABLE ACCESS FULL| DEPT |
| 3 | TABLE ACCESS FULL| EMP |
-----------------------------------
Predicate Information
---------------------------------------
1 - access("D"."DEPTNO"="E"."DEPTNO")
select *
from emp e, dept d
where d.deptno = e.deptno
s
c
a
n
Apply hash function to DEPT.DEPTNO
to find in which bucket to store
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Bucketized hash-table in PGA memory
Build phase
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Phase 1 done
-----------------------------------
| Id | Operation | Name |
-----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | HASH JOIN | |
| 2 | TABLE ACCESS FULL| DEPT |
| 3 | TABLE ACCESS FULL| EMP |
-----------------------------------
Predicate Information
---------------------------------------
1 - access("D"."DEPTNO"="E"."DEPTNO")
select *
from emp e, dept d
where d.deptno = e.deptno
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Phase 2: probe 2nd table (EMP)
-----------------------------------
| Id | Operation | Name |
-----------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | HASH JOIN | |
| 2 | TABLE ACCESS FULL| DEPT |
| 3 | TABLE ACCESS FULL| EMP |
-----------------------------------
Predicate Information
---------------------------------------
1 - access("D"."DEPTNO"="E"."DEPTNO")
select *
from emp e, dept d
where d.deptno = e.deptno
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
s
c
a
n
Apply hash function to EMP.DEPTNO
to find in which bucket to probe for
matching DEPT record
If match found: join and return row
Probe phase
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash joins parallel execution plan
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
QC
P10
P11
P12
P00
P01
P02
Slave set 2 Slave set 1
Assuming DOP = 3
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Build phase
QC
P10
P11
P12
P00
P01
P02
Slave set 2 Slave set 1
Lines 7,6,5: Scan DEPT, hash send to SS2
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
Hash PQ Distrib:
conceptually distributes rows based on
mod(hash(deptno),3)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Build phase
QC
P10
P11
P12
Slave set 2 Slave set 1
Line 4/3: Build hash table for DEPT rows received
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
P00
P01
P02
(still scanning/sending)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash joins parallel execution plan
QC
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
P10
P11
P12
P00
P01
P02
Slave set 2 Slave set 1
Build phase ready
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Probe phase
QC
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
P10
P11
P12
P00
P01
P02
Slave set 2 Slave set 1
Lines 11,10,9: Scan EMP, hash send to SS2
Same mod(hash(deptno),3)
distribution used
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Probe phase
QC
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
P10
P11
P12
Slave set 2 Slave set 1
Line 8/3: Join/probe hash table for EMP rows received
P00
P01
P02
(still scanning/sending)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Probe phase
QC
-------------------------------------------------------------------------
| Id | Operation | Name | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | |
| 1 | PX COORDINATOR | | | | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) |
|* 3 | HASH JOIN | | Q1,02 | PCWP | |
| 4 | PX RECEIVE | | Q1,02 | PCWP | |
| 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH |
| 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | |
| 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | |
| 8 | PX RECEIVE | | Q1,02 | PCWP | |
| 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH |
| 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | |
| 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | |
-------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
P10
P11
P12
Slave set 2 Slave set 1
Lines 2/1: Receive resulting joined rows
P00
P01
P02
(still scanning/sending)
(still receiving/joining)
Point to be made:
Inter slave set traffic = expensive
as 2nd table would be much larger
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Filter early
• What do we mean by “filter early”?
– In the hierarchical execution plan tree
– Eliminate rows as soon (early) as possible
– Preventing their (expensive) flow through parent execution stages in plan
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Filter early: join example
select d.dname,e.ename
from dept d, emp e
where d.deptno = e.deptno
and d.deptno between 130 and 150
Remember this plan
BF’s operate in same way
--------------------------------------------------------
| Id | Operation | Name |
--------------------------------------------------------
| 0 | SELECT STATEMENT | |
|* 1 | HASH JOIN | |
| 2 | TABLE ACCESS BY INDEX ROWID BATCHED| DEPT |
|* 3 | INDEX RANGE SCAN | DEPT_PK |
|* 4 | TABLE ACCESS FULL | EMP | <== Filter!
--------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("D"."DEPTNO"="E"."DEPTNO")
3 - access("D"."DEPTNO">=130 AND "D"."DEPTNO"<=150)
4 - filter(("E"."DEPTNO">=130 AND "E"."DEPTNO"<=150)) <== Filter!
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter concept
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter concept
• Memory structure representing a set of values (say S)
– “representing”  member values are encoded in specific manner
• Memory structure can be used to answer:
– Is a given value x, member of set S?
• Two possible answers
– Definitely not
– Possibly yes
Two operators on structure:
1) Add value x
2) Test membership
Conceived by Burton Howard Bloom in 1970
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter concept
• BF(m,k)
– m = size of memory structure in bits  array of m bits
– k = number of hash functions used to encode value (hf1,…,hfk)
• Range of hash functions is: [0..m]
Bit array initially filled with 0’s
• Adding (encoding) a value x:
– Apply each hash-function to value x  this produces k hash-values
– Set bit in array at each hash-value’s position
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter: adding value 2
Assuming 3 hash functions used
hf1
hf2
hf3
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter: adding value 4
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter: adding value 6
Note:
one of hashes of 6 is same as
one of hashes of 2
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter: testing for membership
• Once bloom filter is populated with complete set, we can test for
membership of any given value
– By just applying hash-functions to given value
– And checking if all hashed positions in bit-array are filled with 1
• If any not filled  then definitely not a member of the set
• If all filled  then possibly (!) member of the set
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Testing value 6
Possibly yes
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Testing value 14
Definitely not
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
False positives possible
• Likelihood increases when bit-array is sized too small
• Demo: https://www.jasondavies.com/bloomfilter/
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter sizing
• CBO uses estimated NDV to size Bloom filter
• Number of Distinct Values
• Demo: http://hur.st/bloomfilter?n=1000000&p=0.01
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Why use Bloom filters?
1. Memory structure is small
– Around 9-10 bits per (distinct) element required for a 1% false positive probability
2. Add and test operators are fast
– Cheap hash + fast set/test bit-operations
 Bloom filters are cheap to create, use and dispose of, on-the-fly
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
How can Bloom filter help filter early in hash joins?
• BF use-cases in hash-join are of the form:
– In BUILD stage of execution plan: BF CREATE
• All join-column values of build-table added to BF
• BF filter = bit signature of join condition
– Then during PROBE stage of execution plan: BF USE
• Every join-column value of probe-table tested against BF
• BF filter used to filter ‘definitely not member’ cases
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Early filtering
HASH JOIN
DEPT EMP
Where-clause predicate
Bloom filter
creation Bloom filter
use
• Bloom filter encodes subset of
DEPT PK join-values
• Used during scan of EMP FK join-
values
• Bloom filter prevents flow of EMP
rows to Hash-Join operator for
which there would not be
matching DEPT row
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom filter examples
• Parallel join filter
• Serial subquery filter
• Multiple BF’s (rightdeep tree)
• Bloom pruning filter
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Parallel join filter
select d.dname,e.ename
from dept d, emp e
where d.deptno = e.deptno
and d.loc = 'UTRECHT'
---------------------------------------------
| Id | Operation | Name |
---------------------------------------------
| 0 | SELECT STATEMENT | |
| 1 | PX COORDINATOR | |
| 2 | PX SEND QC (RANDOM) | :TQ10002 |
|* 3 | HASH JOIN | |
| 4 | JOIN FILTER CREATE | :BF0000 |
| 5 | PX RECEIVE | |
| 6 | PX SEND HASH | :TQ10000 |
| 7 | PX BLOCK ITERATOR | |
|* 8 | TABLE ACCESS FULL| DEPT |
| 9 | PX RECEIVE | |
| 10 | PX SEND HASH | :TQ10001 |
| 11 | JOIN FILTER USE | :BF0000 |
| 12 | PX BLOCK ITERATOR | |
|* 13 | TABLE ACCESS FULL| EMP |
---------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("D"."DEPTNO"="E"."DEPTNO")
8 - filter("D"."LOC"='UTRECHT')
13 - filter(SYS_OP_BLOOM_FILTER(:BF0000,"E"."DEPTNO"))
False positives caught in line 3
What is saved?
1. Less rows distributed SS1  SS2
during probe phase
2. Bit vs byte-string operations
Filter on non-join column (LOC)
used to ‘early filter’ EMP rows
hf1
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Serial subquery filter
select d.dname,e.disnm
from dept d
,(select deptno
,count(distinct ename)
as disnm
from emp
group by deptno) e
where d.loc='UTRECHT‘
and d.deptno = e.deptno
--------------------------------------------------------------
| Id | Operation | Name | Starts | A-Rows |
--------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 11 |
| 1 | HASH GROUP BY | | 1 | 11 |
|* 2 | HASH JOIN | | 1 | 44 |
| 3 | JOIN FILTER CREATE | :BF0000 | 1 | 11 |
|* 4 | TABLE ACCESS FULL | DEPT | 1 | 11 |
| 5 | VIEW | VM_NWVW_1 | 1 | 44 |
| 6 | HASH GROUP BY | | 1 | 44 |
| 7 | JOIN FILTER USE | :BF0000 | 1 | 44 |
|* 8 | TABLE ACCESS FULL| EMP | 1 | 44 |
--------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("D"."DEPTNO"="$vm_col_2")
4 - filter("D"."LOC"='UTRECHT')
8 - filter(SYS_OP_BLOOM_FILTER(:BF0000,"DEPTNO"))BF push through GroupBy
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Multiple Bloom filters
part
date_dim supplier
Line
order
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom pruning filter (11g)
P0
P1
P2
P3
P4
FACT partitioned
DIM
INSERT INTO FACT(...,DIM_FK,...)
VALUES(...,42,...)
Compute_P#_for_FACT(42)
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom pruning filter (11g)
• Shows up as “Partition join filter create”
– When joining DIM to FACT and join-column is input for partitioning scheme of FACT
– Build phase:
• FACT’s partition function is applied to DIM PK values to find P#’s of FACT that would hold such values
• These P#’s are added to Bloom filter
– Probe phase:
• Bloom filter is used when scanning FACT
• Only partitions whose P#’s are in Bloom filter will be scanned
P0
P1
P2
P3
P4
FACT partitioned
DIM
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Bloom pruning filter
---------------------------------------------------------------------
| Id | Operation | Name | Pstart| Pstop |
---------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | |
| 1 | SORT AGGREGATE | | | |
| 2 | PX COORDINATOR | | | |
| 3 | PX SEND QC (RANDOM) | :TQ10001 | | |
| 4 | SORT AGGREGATE | | | |
|* 5 | HASH JOIN | | | |
| 6 | BUFFER SORT | | | |
| 7 | PART JOIN FILTER CREATE| :BF0000 | | |
| 8 | PX RECEIVE | | | |
| 9 | PX SEND BROADCAST | :TQ10000 | | |
|* 10 | TABLE ACCESS FULL | DATE_DIM | | |
| 11 | PX BLOCK ITERATOR | |:BF0000|:BF0000|
|* 12 | TABLE ACCESS FULL | STORE_SALES |:BF0000|:BF0000|
---------------------------------------------------------------------
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Final remarks
• Bloom filter are pushed down to storage cells and DBIM scans
• SQL Monitor report has details on Bloom filter
– V$sql_join_filter
• Hints px_join_filter() / no_px_join_filter()
• alter session set events 'trace[RDBMS.Bloom_filter] …'
• Event 10128 Bloom pruning filter
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Hash function
Hash joins
Bloom filters
Examples
Questions?
Email: toon.koppelaars@oracle.com
Twitter: @toonkoppelaars
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Shameless plug…
• community.oracle.com
• community.oracle.com/ideas
• community.oracle.com/ideas/13028
• If you think declarative generic multi-row constraints are useful
go check it out and vote
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

More Related Content

PDF
Same plan different performance
Mauro Pagano
 
PPSX
JSON in Oracle 18c and 19c
stewashton
 
PDF
Machine Learning in Autonomous Data Warehouse
Sandesh Rao
 
PPTX
AWR and ASH Deep Dive
Kellyn Pot'Vin-Gorman
 
PDF
Oracle statistics by example
Mauro Pagano
 
PDF
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 
PPT
Ash masters : advanced ash analytics on Oracle
Kyle Hailey
 
PPTX
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Carlos Sierra
 
Same plan different performance
Mauro Pagano
 
JSON in Oracle 18c and 19c
stewashton
 
Machine Learning in Autonomous Data Warehouse
Sandesh Rao
 
AWR and ASH Deep Dive
Kellyn Pot'Vin-Gorman
 
Oracle statistics by example
Mauro Pagano
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder
 
Ash masters : advanced ash analytics on Oracle
Kyle Hailey
 
Understanding How is that Adaptive Cursor Sharing (ACS) produces multiple Opt...
Carlos Sierra
 

What's hot (20)

PDF
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Tanel Poder
 
PDF
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Aaron Shilo
 
PDF
Parallel Execution With Oracle Database 12c - Masterclass
Ivica Arsov
 
PDF
How to find what is making your Oracle database slow
SolarWinds
 
PPTX
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Maria Colgan
 
PDF
Chasing the optimizer
Mauro Pagano
 
PDF
One PDB to go, please!
Christian Gohmann
 
PPTX
Oracle sql high performance tuning
Guy Harrison
 
PPT
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
John Kanagaraj
 
PDF
Awr + 12c performance tuning
AiougVizagChapter
 
PPTX
Oracle database performance tuning
Yogiji Creations
 
PPTX
SQL Plan Directives explained
Mauro Pagano
 
PDF
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder
 
PDF
MERGE SQL Statement: Lesser Known Facets
Andrej Pashchenko
 
PPT
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
udaymoogala
 
PDF
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
John Beresniewicz
 
PPT
OOUG: Oracle transaction locking
Kyle Hailey
 
PDF
Migration to Oracle Multitenant
Jitendra Singh
 
PDF
Understanding oracle rac internals part 1 - slides
Mohamed Farouk
 
PPTX
JSON and the Oracle Database
Maria Colgan
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Tanel Poder
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Aaron Shilo
 
Parallel Execution With Oracle Database 12c - Masterclass
Ivica Arsov
 
How to find what is making your Oracle database slow
SolarWinds
 
Part1 of SQL Tuning Workshop - Understanding the Optimizer
Maria Colgan
 
Chasing the optimizer
Mauro Pagano
 
One PDB to go, please!
Christian Gohmann
 
Oracle sql high performance tuning
Guy Harrison
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
John Kanagaraj
 
Awr + 12c performance tuning
AiougVizagChapter
 
Oracle database performance tuning
Yogiji Creations
 
SQL Plan Directives explained
Mauro Pagano
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder
 
MERGE SQL Statement: Lesser Known Facets
Andrej Pashchenko
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
udaymoogala
 
DB Time, Average Active Sessions, and ASH Math - Oracle performance fundamentals
John Beresniewicz
 
OOUG: Oracle transaction locking
Kyle Hailey
 
Migration to Oracle Multitenant
Jitendra Singh
 
Understanding oracle rac internals part 1 - slides
Mohamed Farouk
 
JSON and the Oracle Database
Maria Colgan
 
Ad

Similar to Hash joins and bloom filters at AMIS25 (20)

PPTX
Analysing and troubleshooting Parallel Execution IT Tage 2015
Randolf Geist
 
PDF
Oracle Parallel Distribution and 12c Adaptive Plans
Franck Pachot
 
PDF
Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...
Informatik Aktuell
 
PDF
OracleDatabase12cPXNewFeatures_ITOUG_2018.pdf
7vkx8892hv
 
DOCX
Subquery factoring for FTS
Heribertus Bramundito
 
PPT
Do You Know The 11g Plan?
Mahesh Vallampati
 
PPTX
Oracle optimizer bootcamp
Maria Colgan
 
PPTX
Adaptive Query Optimization
Christian Antognini
 
PPT
Sydney Oracle Meetup - access paths
paulguerin
 
PDF
PoC Oracle Exadata - Retour d'expérience
Swiss Data Forum Swiss Data Forum
 
PPT
Introduction to Parallel Execution
Doug Burns
 
PPT
Dbms plan - A swiss army knife for performance engineers
Riyaj Shamsudeen
 
PPTX
Adaptive Query Optimization in 12c
Anju Garg
 
PDF
My Experience Using Oracle SQL Plan Baselines 11g/12c
Nelson Calero
 
PDF
Oracle Query Tuning Tips - Get it Right the First Time
Dean Richards
 
PPTX
Oracle dbms_xplan.display_cursor format
Franck Pachot
 
PPTX
Top 10 tips for Oracle performance
Guy Harrison
 
PDF
Compute 101 - OpenStack Summit Vancouver 2015
Stephen Gordon
 
PPTX
Oracle Basics and Architecture
Sidney Chen
 
PDF
2010 03 papi_indiana
PTIHPA
 
Analysing and troubleshooting Parallel Execution IT Tage 2015
Randolf Geist
 
Oracle Parallel Distribution and 12c Adaptive Plans
Franck Pachot
 
Randolf Geist – IT-Tage 2015 – Oracle Parallel Execution – Analyse und Troubl...
Informatik Aktuell
 
OracleDatabase12cPXNewFeatures_ITOUG_2018.pdf
7vkx8892hv
 
Subquery factoring for FTS
Heribertus Bramundito
 
Do You Know The 11g Plan?
Mahesh Vallampati
 
Oracle optimizer bootcamp
Maria Colgan
 
Adaptive Query Optimization
Christian Antognini
 
Sydney Oracle Meetup - access paths
paulguerin
 
PoC Oracle Exadata - Retour d'expérience
Swiss Data Forum Swiss Data Forum
 
Introduction to Parallel Execution
Doug Burns
 
Dbms plan - A swiss army knife for performance engineers
Riyaj Shamsudeen
 
Adaptive Query Optimization in 12c
Anju Garg
 
My Experience Using Oracle SQL Plan Baselines 11g/12c
Nelson Calero
 
Oracle Query Tuning Tips - Get it Right the First Time
Dean Richards
 
Oracle dbms_xplan.display_cursor format
Franck Pachot
 
Top 10 tips for Oracle performance
Guy Harrison
 
Compute 101 - OpenStack Summit Vancouver 2015
Stephen Gordon
 
Oracle Basics and Architecture
Sidney Chen
 
2010 03 papi_indiana
PTIHPA
 
Ad

More from Getting value from IoT, Integration and Data Analytics (20)

PPTX
AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...
Getting value from IoT, Integration and Data Analytics
 
PPTX
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
Getting value from IoT, Integration and Data Analytics
 
PPTX
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: SaaS
Getting value from IoT, Integration and Data Analytics
 
PPTX
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 1: Data
Getting value from IoT, Integration and Data Analytics
 
PPTX
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 1: Cloud Infrastructure
Getting value from IoT, Integration and Data Analytics
 
PPTX
10 tips voor verbetering in je Linkedin profiel
Getting value from IoT, Integration and Data Analytics
 
PPTX
Iot in de zorg the next step - fit for purpose
Getting value from IoT, Integration and Data Analytics
 
PPTX
Iot overview .. Best practices and lessons learned by Conclusion Conenct
Getting value from IoT, Integration and Data Analytics
 
PPTX
IoT Fit for purpose - how to be successful in IOT Conclusion Connect
Getting value from IoT, Integration and Data Analytics
 
PPTX
Industry and IOT Overview of protocols and best practices Conclusion Connect
Getting value from IoT, Integration and Data Analytics
 
PPTX
IoT practical case using the people counter sensing traffic density build usi...
Getting value from IoT, Integration and Data Analytics
 
PPTX
Introduction overviewmachinelearning sig Door Lucas Jellema
Getting value from IoT, Integration and Data Analytics
 
PPTX
Oracle OpenWorld 2017 Review (31st October 2017 - 250 slides)
Getting value from IoT, Integration and Data Analytics
 
PPTX
Ethereum smart contracts - door Peter Reitsma
Getting value from IoT, Integration and Data Analytics
 
PPTX
Blockchain - Techniek en usecases door Robert van Molken - AMIS - Conclusion
Getting value from IoT, Integration and Data Analytics
 
PPTX
kennissessie blockchain - Wat is Blockchain en smart contracts @Conclusion
Getting value from IoT, Integration and Data Analytics
 
PPTX
Internet of Things propositie - Enterprise IOT - AMIS - Conclusion
Getting value from IoT, Integration and Data Analytics
 
PDF
Omc AMIS evenement 26012017 Dennis van Soest
Getting value from IoT, Integration and Data Analytics
 
AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...
Getting value from IoT, Integration and Data Analytics
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: Custom Application ...
Getting value from IoT, Integration and Data Analytics
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 2: SaaS
Getting value from IoT, Integration and Data Analytics
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 1: Data
Getting value from IoT, Integration and Data Analytics
 
AMIS Oracle OpenWorld en Code One Review 2018 - Pillar 1: Cloud Infrastructure
Getting value from IoT, Integration and Data Analytics
 
10 tips voor verbetering in je Linkedin profiel
Getting value from IoT, Integration and Data Analytics
 
Iot in de zorg the next step - fit for purpose
Getting value from IoT, Integration and Data Analytics
 
Iot overview .. Best practices and lessons learned by Conclusion Conenct
Getting value from IoT, Integration and Data Analytics
 
IoT Fit for purpose - how to be successful in IOT Conclusion Connect
Getting value from IoT, Integration and Data Analytics
 
Industry and IOT Overview of protocols and best practices Conclusion Connect
Getting value from IoT, Integration and Data Analytics
 
IoT practical case using the people counter sensing traffic density build usi...
Getting value from IoT, Integration and Data Analytics
 
Introduction overviewmachinelearning sig Door Lucas Jellema
Getting value from IoT, Integration and Data Analytics
 
Oracle OpenWorld 2017 Review (31st October 2017 - 250 slides)
Getting value from IoT, Integration and Data Analytics
 
Ethereum smart contracts - door Peter Reitsma
Getting value from IoT, Integration and Data Analytics
 
Blockchain - Techniek en usecases door Robert van Molken - AMIS - Conclusion
Getting value from IoT, Integration and Data Analytics
 
kennissessie blockchain - Wat is Blockchain en smart contracts @Conclusion
Getting value from IoT, Integration and Data Analytics
 
Internet of Things propositie - Enterprise IOT - AMIS - Conclusion
Getting value from IoT, Integration and Data Analytics
 
Omc AMIS evenement 26012017 Dennis van Soest
Getting value from IoT, Integration and Data Analytics
 

Recently uploaded (20)

PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Doc9.....................................
SofiaCollazos
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 

Hash joins and bloom filters at AMIS25

  • 1. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filters Toon Koppelaars Real World Performance team Database Server Technologies
  • 2. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash function Hash joins Bloom filters Agenda Examples
  • 3. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash joins and Bloom filters • Bloom filters (BF) introduced in 10gR2 – Enable CBO to “filter early” in hash joins – Used automatically, visible in execution plan • Implemented to speed up large parallel hash joins (DWH/BI) – BF’s prevent unnecessary row-transport between parallel query slave sets • As of 11.2.0.4 BF’s may also show up in serial plans
  • 4. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash joins explained ----------------------------------- | Id | Operation | Name | ----------------------------------- | 0 | SELECT STATEMENT | | |* 1 | HASH JOIN | | | 2 | TABLE ACCESS FULL| DEPT | | 3 | TABLE ACCESS FULL| EMP | ----------------------------------- Predicate Information --------------------------------------- 1 - access("D"."DEPTNO"="E"."DEPTNO") select * from emp e, dept d where d.deptno = e.deptno
  • 5. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | What is a hash-function? – Hash function application is cheap – Hash values are typically “evenly distributed” in range • Irrespective of distribution of input values – Collisions can occur • Two domain values map to same hash value • Since #domain >> #range Domain Range Hash function Digital data Byte strings of any length “Hash values” Offset between [0..some-power-of-2 minus 1]
  • 6. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
  • 7. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Phase 1: build hash table (DEPT) ----------------------------------- | Id | Operation | Name | ----------------------------------- | 0 | SELECT STATEMENT | | |* 1 | HASH JOIN | | | 2 | TABLE ACCESS FULL| DEPT | | 3 | TABLE ACCESS FULL| EMP | ----------------------------------- Predicate Information --------------------------------------- 1 - access("D"."DEPTNO"="E"."DEPTNO") select * from emp e, dept d where d.deptno = e.deptno s c a n Apply hash function to DEPT.DEPTNO to find in which bucket to store 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bucketized hash-table in PGA memory Build phase
  • 8. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Phase 1 done ----------------------------------- | Id | Operation | Name | ----------------------------------- | 0 | SELECT STATEMENT | | |* 1 | HASH JOIN | | | 2 | TABLE ACCESS FULL| DEPT | | 3 | TABLE ACCESS FULL| EMP | ----------------------------------- Predicate Information --------------------------------------- 1 - access("D"."DEPTNO"="E"."DEPTNO") select * from emp e, dept d where d.deptno = e.deptno 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  • 9. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Phase 2: probe 2nd table (EMP) ----------------------------------- | Id | Operation | Name | ----------------------------------- | 0 | SELECT STATEMENT | | |* 1 | HASH JOIN | | | 2 | TABLE ACCESS FULL| DEPT | | 3 | TABLE ACCESS FULL| EMP | ----------------------------------- Predicate Information --------------------------------------- 1 - access("D"."DEPTNO"="E"."DEPTNO") select * from emp e, dept d where d.deptno = e.deptno 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 s c a n Apply hash function to EMP.DEPTNO to find in which bucket to probe for matching DEPT record If match found: join and return row Probe phase
  • 10. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash joins parallel execution plan ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") QC P10 P11 P12 P00 P01 P02 Slave set 2 Slave set 1 Assuming DOP = 3
  • 11. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Build phase QC P10 P11 P12 P00 P01 P02 Slave set 2 Slave set 1 Lines 7,6,5: Scan DEPT, hash send to SS2 ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") Hash PQ Distrib: conceptually distributes rows based on mod(hash(deptno),3)
  • 12. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Build phase QC P10 P11 P12 Slave set 2 Slave set 1 Line 4/3: Build hash table for DEPT rows received ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") P00 P01 P02 (still scanning/sending)
  • 13. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash joins parallel execution plan QC ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") P10 P11 P12 P00 P01 P02 Slave set 2 Slave set 1 Build phase ready
  • 14. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Probe phase QC ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") P10 P11 P12 P00 P01 P02 Slave set 2 Slave set 1 Lines 11,10,9: Scan EMP, hash send to SS2 Same mod(hash(deptno),3) distribution used
  • 15. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Probe phase QC ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") P10 P11 P12 Slave set 2 Slave set 1 Line 8/3: Join/probe hash table for EMP rows received P00 P01 P02 (still scanning/sending)
  • 16. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Probe phase QC ------------------------------------------------------------------------- | Id | Operation | Name | TQ |IN-OUT| PQ Distrib | ------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | | 1 | PX COORDINATOR | | | | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | Q1,02 | P->S | QC (RAND) | |* 3 | HASH JOIN | | Q1,02 | PCWP | | | 4 | PX RECEIVE | | Q1,02 | PCWP | | | 5 | PX SEND HASH | :TQ10000 | Q1,00 | P->P | HASH | | 6 | PX BLOCK ITERATOR | | Q1,00 | PCWC | | | 7 | TABLE ACCESS FULL| DEPT | Q1,00 | PCWP | | | 8 | PX RECEIVE | | Q1,02 | PCWP | | | 9 | PX SEND HASH | :TQ10001 | Q1,01 | P->P | HASH | | 10 | PX BLOCK ITERATOR | | Q1,01 | PCWC | | | 11 | TABLE ACCESS FULL| EMP | Q1,01 | PCWP | | ------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") P10 P11 P12 Slave set 2 Slave set 1 Lines 2/1: Receive resulting joined rows P00 P01 P02 (still scanning/sending) (still receiving/joining) Point to be made: Inter slave set traffic = expensive as 2nd table would be much larger
  • 17. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Filter early • What do we mean by “filter early”? – In the hierarchical execution plan tree – Eliminate rows as soon (early) as possible – Preventing their (expensive) flow through parent execution stages in plan
  • 18. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Filter early: join example select d.dname,e.ename from dept d, emp e where d.deptno = e.deptno and d.deptno between 130 and 150 Remember this plan BF’s operate in same way -------------------------------------------------------- | Id | Operation | Name | -------------------------------------------------------- | 0 | SELECT STATEMENT | | |* 1 | HASH JOIN | | | 2 | TABLE ACCESS BY INDEX ROWID BATCHED| DEPT | |* 3 | INDEX RANGE SCAN | DEPT_PK | |* 4 | TABLE ACCESS FULL | EMP | <== Filter! -------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("D"."DEPTNO"="E"."DEPTNO") 3 - access("D"."DEPTNO">=130 AND "D"."DEPTNO"<=150) 4 - filter(("E"."DEPTNO">=130 AND "E"."DEPTNO"<=150)) <== Filter!
  • 19. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter concept
  • 20. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter concept • Memory structure representing a set of values (say S) – “representing”  member values are encoded in specific manner • Memory structure can be used to answer: – Is a given value x, member of set S? • Two possible answers – Definitely not – Possibly yes Two operators on structure: 1) Add value x 2) Test membership Conceived by Burton Howard Bloom in 1970
  • 21. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter concept • BF(m,k) – m = size of memory structure in bits  array of m bits – k = number of hash functions used to encode value (hf1,…,hfk) • Range of hash functions is: [0..m] Bit array initially filled with 0’s • Adding (encoding) a value x: – Apply each hash-function to value x  this produces k hash-values – Set bit in array at each hash-value’s position
  • 22. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter: adding value 2 Assuming 3 hash functions used hf1 hf2 hf3
  • 23. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter: adding value 4
  • 24. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter: adding value 6 Note: one of hashes of 6 is same as one of hashes of 2
  • 25. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter: testing for membership • Once bloom filter is populated with complete set, we can test for membership of any given value – By just applying hash-functions to given value – And checking if all hashed positions in bit-array are filled with 1 • If any not filled  then definitely not a member of the set • If all filled  then possibly (!) member of the set
  • 26. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Testing value 6 Possibly yes
  • 27. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Testing value 14 Definitely not
  • 28. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | False positives possible • Likelihood increases when bit-array is sized too small • Demo: https://www.jasondavies.com/bloomfilter/
  • 29. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter sizing • CBO uses estimated NDV to size Bloom filter • Number of Distinct Values • Demo: http://hur.st/bloomfilter?n=1000000&p=0.01
  • 30. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Why use Bloom filters? 1. Memory structure is small – Around 9-10 bits per (distinct) element required for a 1% false positive probability 2. Add and test operators are fast – Cheap hash + fast set/test bit-operations  Bloom filters are cheap to create, use and dispose of, on-the-fly
  • 31. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | How can Bloom filter help filter early in hash joins? • BF use-cases in hash-join are of the form: – In BUILD stage of execution plan: BF CREATE • All join-column values of build-table added to BF • BF filter = bit signature of join condition – Then during PROBE stage of execution plan: BF USE • Every join-column value of probe-table tested against BF • BF filter used to filter ‘definitely not member’ cases
  • 32. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Early filtering HASH JOIN DEPT EMP Where-clause predicate Bloom filter creation Bloom filter use • Bloom filter encodes subset of DEPT PK join-values • Used during scan of EMP FK join- values • Bloom filter prevents flow of EMP rows to Hash-Join operator for which there would not be matching DEPT row
  • 33. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom filter examples • Parallel join filter • Serial subquery filter • Multiple BF’s (rightdeep tree) • Bloom pruning filter
  • 34. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Parallel join filter select d.dname,e.ename from dept d, emp e where d.deptno = e.deptno and d.loc = 'UTRECHT' --------------------------------------------- | Id | Operation | Name | --------------------------------------------- | 0 | SELECT STATEMENT | | | 1 | PX COORDINATOR | | | 2 | PX SEND QC (RANDOM) | :TQ10002 | |* 3 | HASH JOIN | | | 4 | JOIN FILTER CREATE | :BF0000 | | 5 | PX RECEIVE | | | 6 | PX SEND HASH | :TQ10000 | | 7 | PX BLOCK ITERATOR | | |* 8 | TABLE ACCESS FULL| DEPT | | 9 | PX RECEIVE | | | 10 | PX SEND HASH | :TQ10001 | | 11 | JOIN FILTER USE | :BF0000 | | 12 | PX BLOCK ITERATOR | | |* 13 | TABLE ACCESS FULL| EMP | --------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 3 - access("D"."DEPTNO"="E"."DEPTNO") 8 - filter("D"."LOC"='UTRECHT') 13 - filter(SYS_OP_BLOOM_FILTER(:BF0000,"E"."DEPTNO")) False positives caught in line 3 What is saved? 1. Less rows distributed SS1  SS2 during probe phase 2. Bit vs byte-string operations Filter on non-join column (LOC) used to ‘early filter’ EMP rows hf1
  • 35. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Serial subquery filter select d.dname,e.disnm from dept d ,(select deptno ,count(distinct ename) as disnm from emp group by deptno) e where d.loc='UTRECHT‘ and d.deptno = e.deptno -------------------------------------------------------------- | Id | Operation | Name | Starts | A-Rows | -------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 11 | | 1 | HASH GROUP BY | | 1 | 11 | |* 2 | HASH JOIN | | 1 | 44 | | 3 | JOIN FILTER CREATE | :BF0000 | 1 | 11 | |* 4 | TABLE ACCESS FULL | DEPT | 1 | 11 | | 5 | VIEW | VM_NWVW_1 | 1 | 44 | | 6 | HASH GROUP BY | | 1 | 44 | | 7 | JOIN FILTER USE | :BF0000 | 1 | 44 | |* 8 | TABLE ACCESS FULL| EMP | 1 | 44 | -------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("D"."DEPTNO"="$vm_col_2") 4 - filter("D"."LOC"='UTRECHT') 8 - filter(SYS_OP_BLOOM_FILTER(:BF0000,"DEPTNO"))BF push through GroupBy
  • 36. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Multiple Bloom filters part date_dim supplier Line order
  • 37. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom pruning filter (11g) P0 P1 P2 P3 P4 FACT partitioned DIM INSERT INTO FACT(...,DIM_FK,...) VALUES(...,42,...) Compute_P#_for_FACT(42)
  • 38. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom pruning filter (11g) • Shows up as “Partition join filter create” – When joining DIM to FACT and join-column is input for partitioning scheme of FACT – Build phase: • FACT’s partition function is applied to DIM PK values to find P#’s of FACT that would hold such values • These P#’s are added to Bloom filter – Probe phase: • Bloom filter is used when scanning FACT • Only partitions whose P#’s are in Bloom filter will be scanned P0 P1 P2 P3 P4 FACT partitioned DIM
  • 39. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Bloom pruning filter --------------------------------------------------------------------- | Id | Operation | Name | Pstart| Pstop | --------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | | 1 | SORT AGGREGATE | | | | | 2 | PX COORDINATOR | | | | | 3 | PX SEND QC (RANDOM) | :TQ10001 | | | | 4 | SORT AGGREGATE | | | | |* 5 | HASH JOIN | | | | | 6 | BUFFER SORT | | | | | 7 | PART JOIN FILTER CREATE| :BF0000 | | | | 8 | PX RECEIVE | | | | | 9 | PX SEND BROADCAST | :TQ10000 | | | |* 10 | TABLE ACCESS FULL | DATE_DIM | | | | 11 | PX BLOCK ITERATOR | |:BF0000|:BF0000| |* 12 | TABLE ACCESS FULL | STORE_SALES |:BF0000|:BF0000| ---------------------------------------------------------------------
  • 40. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Final remarks • Bloom filter are pushed down to storage cells and DBIM scans • SQL Monitor report has details on Bloom filter – V$sql_join_filter • Hints px_join_filter() / no_px_join_filter() • alter session set events 'trace[RDBMS.Bloom_filter] …' • Event 10128 Bloom pruning filter
  • 41. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Hash function Hash joins Bloom filters Examples Questions? Email: [email protected] Twitter: @toonkoppelaars
  • 42. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Shameless plug… • community.oracle.com • community.oracle.com/ideas • community.oracle.com/ideas/13028 • If you think declarative generic multi-row constraints are useful go check it out and vote
  • 43. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |