[Pljava-dev] Re: Question about java in Postgresql

Thomas Hallgren thhal at mailblocks.com
Fri Mar 25 14:38:53 UTC 2005


Acarlos wrote:

> Hi my name is Antonio Carlos, from Campos - Rio de Janeiro - Brazil, 
>  i´m student of science computer specialized in RBMS, and i'm trying 
> write article about  PostgreSQL's function written java.
> Please, help me answering some questions:
>
> 1) Why to write  PostgreSQL's function in Java and not in other language?

A couple of reasons come to mind:

1. SQL 2003 defines an elaborate standard for Java SQL mappings and 
several database vendors follow this standard. PL/Java for PostgreSQL is 
no exception. Thus, writing in Java will give you good database vendor 
independence.

2. If your middle tier is a Java application server (EJB, Servlet 
engine, JSP, etc.) you already have a lot of functionality written i 
Java. Some of this functionality might have a high level of database 
interaction. Moving such functionality into functions executed by the 
backend will decrease the protocol overhead and might improve 
performance significantly. If Java is the language in the backend as 
well as in the middle tier, the efforts needed for such moves typically 
very small. Also, by limiting the number of languages used by an 
application, you make the application easier to maintain and the source 
more coherent.

3. Java has an extensive runtime library. JDBC access, XML parsers, URL 
resolvers, regular expressions, logging facilities, collection packages, 
etc. etc. is all part of the runtime and readily available. It's also 
standardized.

4. A Modern JVM is extremely fast. While a normal C/C++ compiler can 
optimize code at compile time, A JVM can continue to optimize the code 
in runtime as well.

5. Java is object oriented, strongly typed, promotes 
interface/implementation separation, uses an efficient garbage 
collector,  and is in many other respects a very modern and elaborate 
language.

6. Several excellent free Java-IDE's exists.

> 2) Java is faster(run-time) than other language?

5. It depends on the application. Complex functions executing in a 
long-lived JVM tends to outperform most other languages since the JVM 
continuously improves the code at runtime. Short lived JVM's suffer from 
startup overhead and will not benefit the same way from runtime 
optimizations. So you can get all from poor performance to excellent 
(faster then most other languages) depending on what you do and how you 
do it.

> 3) How long time Java is support to write PostgreSQL, not just in 
> pljava, but the Java language.

The JDBC client driver has been around for a while (see 
jdbc.postgresql.org for more info). I'm not sure how long but several 
years. The first release of PL/Java was in January this year. Another 
project, the PL/J http://plj.codehaus.org has not yet reached it's first 
release.

> Thanks a lot, and maybe a need to write again, if you didn´t die 
> reading my email! Uh! That's email badly written!

If/when you write again, please direct your questions to the mail group 
pljava-dev at gborg.postgresql.org rather than me personally. This is an 
open source community and the benefits of openness works both ways. You 
might get more input and answers to questions might be good reading for 
others as well.

Regards,
Thomas Hallgren




More information about the Pljava-dev mailing list