Are Java stored procedures slower than PL/SQL in Oracle?

3.9k Views Asked by At

This is a straightforward question: do you know if Java stored procedures are slower than PL/SQL in a Oracle database?

We've migrated a stored procedure from PL/SQL to Java just to benchmark it and it's taking approximately two times the time of the PL/SQL one. Is this also your experience?

Thanks.

2

There are 2 best solutions below

0
On

Whenever you switch between languages you will incur an overhead, called a context switch.

( http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:60122715103602 )

There is even an overhead in moving between SQL and PL/SQL and they are very tightly integrated. Moving between Java and PL/SQL will therefore always be less efficient than pure PL/SQL.

Java Stored Procedure Vs PL/SQL Stored Procedure

As for the performance once the context switching has taken place, your benchmarking will give you the best answer but FWIW, as PL/SQL is so tightly integrated within the Oracle database it should perform better than the stored Java code if you are fetching data or interacting with the DB, if you are purely manipulating already fetched data, it would depend upon what you are then doing to the data and your benchmark will tell you the answer.

0
On

Yes. Java has always been the fattest, slowest kid on the block.

There's no reason to switch from pl/sql to java for 99% of what you might do.

I use java for the few instances I need to.