You are on page 1of 6

Oracle Performance And Tuning

Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 1
Bulk-Binds And BULK COLLECT Concepts in
PL/SQL

Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 2
• When Using BULK COLLECT Whenever Large Volumes of
Data is Fetched
• Programs Might Run Much Faster(Advantage)
• Consuming Too Much Memory(Dis-Advantage)
• The Tradeoff With BULK COLLECT Implementation is,
"Run Faster But Consume More Memory.“
Architectural Point of Concentration
• Memory For Collections is Stored in The Program Global
Area (PGA) But Not in System Global Area (SGA) As
Collections Are Part of SQL.
• SGA Memory is Shared By All Sessions Connected To
Oracle Database, Whereas PGA Memory is Allocated
For Each Session Individually and Independently.
Memory Allocation Expression
Total_Memory_Load = (P_Mem * N_Conn) + Total_SGA
Illustration
Memory Required By A Particular Program(PGA) = 5MB
Number of Simultaneous Connections = 100
Total Amount of Memory For All Simultaneous = 5 * 100
Total PGA Demanded By The Program is = 500MB
Total Memory Load on The Instance Server is = 500 + SGA
Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 3
What is The Solution?
• PL/SQL Developers Should Control The Amount of
Memory Used in A Bulk Collect Operation By Using The
LIMIT Clause.
Bulk Collect Implementation Stratgies
Bulk Collect Strategy 01
• In This Strategy We Populate Collections Directly From
SQL Using BULK COLLECT.
Bulk Collect Strategy 02
• Hold The Collections in The Memory And Start Handling
The Data Load Process,
• PL/SQL Developer Should Take Care To See That The
Collection Size is Not Beyond The Resources.
Bulk Collect Strategy 03
• Implicit Array Processing, Using Bulk Collect.
• In This Case The PL/SQL Developer Should Manage The
LIMIT Clause By Heuristic Calculation of The PGA
Available.
Bulk Collect Strategy 04
• Bind Data in Collections into DML Using FORALL.
• This Concept Should Be Used When Inserting The Data.
Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 4
Collection Types
• Dense Collection
• In This The Data in The Collection is Continuous And
No Gaps Exist Between The Records.
• Sparse Collection
• In This The Data in The Collection is Non-Continuous
And Gaps Can Be Identified in Between.
Points To Note
• Use INDICIES OF And VALUES OF Clause For Sparse
Collections.
• INDICES OF Clause Allows A Bulk Operation on A
Sparse Collection By Removing The Reference To
Specific Elements.
• Using INDICIES OF Clause We Can Specify Upper And
Lower Bounds Using The BETWEEN Clause.
Syntax
FORALL Index IN INDICES OF Collection
FORALL Index IN INDICES OF Collection BETWEEN … AND …
• VALUES OF Clause Allows The Values of One
Collection To Be Used As Index Pointers To Another
Collection.
Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 5
Collection Types
• Dense Collection
• In This The Data in The Collection is Continuous And
No Gaps Exist Between The Records.
• Sparse Collection
• In This The Data in The Collection is Non-Continuous
And Gaps Can Be Identified in Between.
Points To Note
• Use INDICIES OF And VALUES OF Clause For Sparse
Collections.
• INDICES OF Clause Allows A Bulk Operation on A
Sparse Collection By Removing The Reference To
Specific Elements.
• Using INDICIES OF Clause We Can Specify Upper And
Lower Bounds Using The BETWEEN Clause.
Syntax
FORALL Index IN INDICES OF Collection
FORALL Index IN INDICES OF Collection BETWEEN … AND …
• VALUES OF Clause Allows The Values of One
Collection To Be Used As Index Pointers To Another
Collection.
Thursday, May 04, 2017 Performance And Tuning By Sathish Yellanki Slide No : 6

You might also like