agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] pljava reninitializing jdbc connection pool for every	invocation
Date: Tue, 21 Mar 2006 19:19:24 +0100
Message-ID: <442043AC.1070702@tada.se> (raw)
In-Reply-To: <6992E470F12A444BB787B5C937B9D4DF03C48ACF@ca-mail1.cis.local>
References: <6992E470F12A444BB787B5C937B9D4DF03C48ACF@ca-mail1.cis.local>

Sriram Dandapani wrote:


> How thread-safe is this connection. If I were to use just 1 connection,
> does pljava guarantee safe concurrent access
>
>   

There will never be concurrent access to a connection. PostgreSQL 
guarantees that, not PL/Java.


> Which begs the question:
>
> Does every call to pljava function create a separate jvm...

No, of course not. It's one JVM *per connection*. You can have millions 
of calls per connection. My point is, they are never parallel so you 
have absolutely no use of a pool from within a PostgreSQL function (be 
it Java or some other language).


> Lets say
> there are cron jobs that are kicked off periodically and lots of
> postgres functions are invoked. Each function calls the pljava function
> several times. What is the overhead in terms of jvm startup/connection
> creation?
>
>   

Each new connection spawns a new JVM. During the life of the connection, 
each call is extremely efficient (due to in-process calls).


> Does the java function that obtains the connection need to worry about
> all this or is a simple jdbc connection creation mechanism sufficient. I
> am not familiar with pljava internals.
>
>   
I'm sorry. I don't understand this question. Worry about what exactly?


> Also, do we need to use the postgresql.jar file or will just pljava be
> sufficient
>
>   

PL/Java has its own JDBC driver. This driver is special in that it will 
connect you to the current transaction (the transaction in which the 
PL/Java function call was made). Each call you make using this driver 
will execute within the scope of the current transaction. If your 
objective is to have autonomous transactions that execute independently 
of the one that is current, then you must connect to another session, 
i.e. another backend process. That in turn, will require you to use the 
client jdbc driver (i.e. the postgresql.jar).

Regards,
Thomas Hallgren






view thread (5+ messages)  latest in thread

Message-ID: <442043AC.1070702@tada.se>
Permalink:  ../442043AC.1070702@tada.se/
Also on:    postgresql.org/message-id/442043AC.1070702@tada.se

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] pljava reninitializing jdbc connection pool for every	invocation
  In-Reply-To: <442043AC.1070702@tada.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox