Skip to content
_CORE
AI & Agentic Systems Core Information Systems Cloud & Platform Engineering Data Platform & Integration Security & Compliance QA, Testing & Observability IoT, Automation & Robotics Mobile & Digital Banking & Finance Insurance Public Administration Defense & Security Healthcare Energy & Utilities Telco & Media Manufacturing Logistics & E-commerce Retail & Loyalty
References Technologies Blog Know-how Tools
About Collaboration Careers
CS EN DE
Let's talk

PL/SQL Optimization of Stored Procedures in Oracle

14. 02. 2012 1 min read CORE SYSTEMSdata
PL/SQL Optimization of Stored Procedures in Oracle

A nightly batch recalculates insurance premiums for 800,000 policies — it takes 6 hours. The nightly window is 4 hours. DBMS_PROFILER revealed: row-by-row processing, COMMIT inside a loop, no BULK operations.

BULK COLLECT and FORALL

BULK COLLECT loads data into a collection all at once. FORALL performs DML in a single roundtrip. LIMIT 10000 for reasonable memory consumption. COMMIT after each batch instead of after each row.

SQL Instead of PL/SQL

A function rewritten as a SQL CASE expression. The entire batch replaced by a single UPDATE statement. 800,000 context switches eliminated. Result: from 6 hours to 8 minutes.

Parallel DML

The PARALLEL hint cut the batch down to 3 minutes. Caution — this requires an exclusive lock on the table.

Lessons Learned

Row-by-row processing is the main performance killer in PL/SQL. Prefer BULK operations or pure SQL. Profile — don’t guess at the bottleneck.

pl/sqloracleperformancedatabase
Share:

CORE SYSTEMS

We build core systems and AI agents that keep operations running. 15 years of experience with enterprise IT.

Need help with implementation?

Our experts can help with design, implementation, and operations. From architecture to production.

Contact us