Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: java stored procedures fast, but slow when called as SQL function

Re: java stored procedures fast, but slow when called as SQL function

From: Nuno Souto <wizofoz2k_at_yahoo.com.au>
Date: 8 Apr 2003 23:39:01 -0700
Message-ID: <73e20c6c.0304082239.78808f76@posting.google.com>


pete_at_mynix.org wrote in message news:<1049837717.61400.0_at_ersa.uk.clara.net>...

>
> Yes: Java as a language is clearly faster than PL/SQL (you can measure
> yourself),

believe me: I've tried. Every signle time Java comes up considerably slower than PL/SQL...

> the JIT compiler techniques have been very well developed
> over the years, and in many cases Java can keep up somewhat with
> native languages such as C.

That might be true in a standalone JVM environment. I still have to see that happen in Oracle, Websphere or anywhere else that has to repeatedly invoke code in a tight loop from a JVM.

>
> The only problem, as I think I have measured, is the binding between
> the SQL engine and PL/SQL.

You measured a problem in the binding between SQL and Java. There is NO problem with the PL/SQL and SQL binding.

>
> When the SQL engine has to shell out to call a function, a switch into
> the JVM takes a relatively long time (about 6 times as long as a
> switch into PL/SQL).

In common with ANY other environment that has to repeatedly shell out to a JVM. The problem is the nature of the JVM, not Java or SQL or PL/SQL. It's a monumental context switch that invalidates just about EVERY execution pipeline and EVERY internal processor cache. That is as lethal to performance as it can get nowadays.

>
> Since Oracle implemented their own JVM, they even implemented many of
> the standard JDK classes in native code, I don't understand why they
> could not have implemented the same level of tight coupling between
> the JVM and SQL as they have done for PL/SQL and SQL.

I think they didn't implement their own. They picked up a third party one and got it going. And they sort of "discourage" people running Java INSIDE the database engine nowadays. Much better to pick up an external JVM (with all that JIT stuff) and use jdbc to get at the data.

Having said that, and before I get the usual barrage of URLs that "prove" Oracle still supports Java inside the db, let me stress it once again: Oracle ACTIVELY discourages anyone from using the in-built JVM in the database. Trust me, OK? ;)

>
> They have been working on this for years, and even are actively
> promoting the use of Java. I see no fundamental reasons or issues with
> Java as a language that would prevent the same level of integration
> with SQL.

They actively promote the use of Java outside of the database engine. I think you should start looking at it from that angle rather than beating your head against the wall...

Cheers
Nuno Souto
wizofoz2k_at_yahoo.com.au.nospam Received on Wed Apr 09 2003 - 01:39:01 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US