pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
JDBC Overhead
5+ messages / 5 participants
[nested] [flat]

* JDBC Overhead
@ 2006-08-01 20:05 Bob Damato <bob_damato@coxtarget.com>
  2006-08-02 00:40 ` Re: JDBC Overhead John R Pierce <pierce@hogranch.com>
  2006-08-02 00:53 ` Re: JDBC Overhead Dave Cramer <pg@fastcrypt.com>
  2006-08-02 03:06 ` Re: JDBC Overhead Guy Rouillier <guyr@masergy.com>
  2006-08-02 03:34 ` Re: JDBC Overhead Oliver Jowett <oliver@opencloud.com>
  0 siblings, 4 replies; 5+ messages in thread

From: Bob Damato @ 2006-08-01 20:05 UTC (permalink / raw)
  To: pgsql-jdbc

It appears to me as if there is quite a bit of overhead with the
Postgres JDBC driver when compared with other JDBC drivers. This simple
piece of code shows me something very odd:

-------------------------------------------------------
ps = con.prepareStatement("SELECT 1");
long execStart = System.currentTimeMillis();
rs = ps.executeQuery();
System.err.println ("Query executed in " + (System.currentTimeMillis() -
execStart) + "ms");
--------------------------------------------------------

Result of this code is:
Query executed in 57ms

But with duration logging enabled on the database side, I can see that
the database side processing time was less than 1 ms.
LOG:  duration: 0.073 ms  statement: EXECUTE <unnamed>  [PREPARE:
SELECT 1]

When I run this same code against a mySQL or Sybase database, I get 1ms
execution time. Am I missing some bit of tuning that I can do with the
database or the JDBC driver to eliminate that 50+ms of latency?

I am running postgres 8.1.4 on solaris and I've tried all 3 JDBC
drivers. The java program is running on the same server as the database
so I don't believe there is any network latency involved.

Thanks!!


________________________________________________________________________
_____________
Bob Damato
Cox Target Media	
Internet Technology Manager
Largo, Florida

Our greatest glory is not in never falling, but in rising every time we
fall.  -- Confucius

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: JDBC Overhead
  2006-08-01 20:05 JDBC Overhead Bob Damato <bob_damato@coxtarget.com>
@ 2006-08-02 00:40 ` John R Pierce <pierce@hogranch.com>
  3 siblings, 0 replies; 5+ messages in thread

From: John R Pierce @ 2006-08-02 00:40 UTC (permalink / raw)
  To: Bob Damato <bob_damato@coxtarget.com>; +Cc: pgsql-jdbc


> When I run this same code against a mySQL or Sybase database, I get 
> 1ms execution time. Am I missing some bit of tuning that I can do with 
> the database or the JDBC driver to eliminate that 50+ms of latency?
>


What do you get when you execute (from a shell prompt, assuming you're 
on a unix type system),

    $ time psql -c "SELECT 1;"  dbname username

unluckily, this won't work if password authentication is required, 
unless you setup a ~/.pgpass

I get about 12mS on a several year old x86 linux server





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: JDBC Overhead
  2006-08-01 20:05 JDBC Overhead Bob Damato <bob_damato@coxtarget.com>
@ 2006-08-02 00:53 ` Dave Cramer <pg@fastcrypt.com>
  3 siblings, 0 replies; 5+ messages in thread

From: Dave Cramer @ 2006-08-02 00:53 UTC (permalink / raw)
  To: Bob Damato <bob_damato@coxtarget.com>; +Cc: pgsql-jdbc

Bob,

On other systems try putting the start time before the prepareStatement

Depending on the system they will parse the statement in the prepare,  
we defer server side parsing until the execute.

Also what is the overhead of a second executeQuery ?

Dave
On 1-Aug-06, at 4:05 PM, Bob Damato wrote:

> It appears to me as if there is quite a bit of overhead with the  
> Postgres JDBC driver when compared with other JDBC drivers. This  
> simple piece of code shows me something very odd:
>
> -------------------------------------------------------
> ps = con.prepareStatement("SELECT 1");
> long execStart = System.currentTimeMillis();
> rs = ps.executeQuery();
> System.err.println ("Query executed in " + (System.currentTimeMillis 
> () - execStart) + "ms");
> --------------------------------------------------------
>
> Result of this code is:
> Query executed in 57ms
>
> But with duration logging enabled on the database side, I can see  
> that the database side processing time was less than 1 ms.
>
> LOG:  duration: 0.073 ms  statement: EXECUTE <unnamed>  [PREPARE:   
> SELECT 1]
>
> When I run this same code against a mySQL or Sybase database, I get  
> 1ms execution time. Am I missing some bit of tuning that I can do  
> with the database or the JDBC driver to eliminate that 50+ms of  
> latency?
>
> I am running postgres 8.1.4 on solaris and I've tried all 3 JDBC  
> drivers. The java program is running on the same server as the  
> database so I don't believe there is any network latency involved.
>
> Thanks!!
>
>
> ______________________________________________________________________ 
> _______________
> Bob  
> Damato                                                                 
>          Cox Target Media
> Internet Technology  
> Manager                                                                
>                                       Largo, Florida
>
> Our greatest glory is not in never falling, but in rising every  
> time we fall.  -- Confucius
>

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: JDBC Overhead
  2006-08-01 20:05 JDBC Overhead Bob Damato <bob_damato@coxtarget.com>
@ 2006-08-02 03:06 ` Guy Rouillier <guyr@masergy.com>
  3 siblings, 0 replies; 5+ messages in thread

From: Guy Rouillier @ 2006-08-02 03:06 UTC (permalink / raw)
  To: pgsql-jdbc

Bob Damato wrote:
> It appears to me as if there is quite a bit of overhead with the
> Postgres JDBC driver when compared with other JDBC drivers. This
> simple piece of code shows me something very odd:
> -------------------------------------------------------  
> ps = con.prepareStatement("SELECT 1");
> long execStart = System.currentTimeMillis();
> rs = ps.executeQuery();
> System.err.println ("Query executed in " +
> (System.currentTimeMillis() - execStart) + "ms");
> -------------------------------------------------------- 
> Result of this code is:
> Query executed in 57ms
> But with duration logging enabled on the database side, I can see
> that the database side processing time was less than 1 ms. 
> LOG:  duration: 0.073 ms  statement: EXECUTE <unnamed>  [PREPARE: 
> SELECT 1] 
> When I run this same code against a mySQL or Sybase database, I get
> 1ms execution time. Am I missing some bit of tuning that I can do
> with the database or the JDBC driver to eliminate that 50+ms of
> latency? I am running postgres 8.1.4 on solaris and I've tried all 3
> JDBC drivers. The java program is running on the same server as the
> database so I don't believe there is any network latency involved.    

When you say you get 1 ms with mySQL and Sybase, is that just the query
or the JDBC code?  1 ms seems rather fantastic to be able traverse all
those execution paths.

If you are running all three in the same configuration - JDBC app and DB
engine on the same box - then check to make sure they are all either
using the network stack or all bypassing it.

-- 
Guy Rouillier



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: JDBC Overhead
  2006-08-01 20:05 JDBC Overhead Bob Damato <bob_damato@coxtarget.com>
@ 2006-08-02 03:34 ` Oliver Jowett <oliver@opencloud.com>
  3 siblings, 0 replies; 5+ messages in thread

From: Oliver Jowett @ 2006-08-02 03:34 UTC (permalink / raw)
  To: Bob Damato <bob_damato@coxtarget.com>; +Cc: pgsql-jdbc

Bob Damato wrote:

> -------------------------------------------------------
> ps = con.prepareStatement("SELECT 1");
> long execStart = System.currentTimeMillis();
> rs = ps.executeQuery();
> System.err.println ("Query executed in " + (System.currentTimeMillis() - 
> execStart) + "ms");
> --------------------------------------------------------
> 
> Result of this code is:
> Query executed in 57ms

Try a better benchmark, what you are probably measuring there is mostly 
classloading, JIT, and similar startup costs. How long does it take on 
the 1000th execution?

Also, unless you are specifically measuring query time when reexecuting 
the same PreparedStatement many times, you should include the cost of 
prepareStatement() in your measurements.

-O



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2006-08-02 03:34 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01 20:05 JDBC Overhead Bob Damato <bob_damato@coxtarget.com>
2006-08-02 00:40 ` John R Pierce <pierce@hogranch.com>
2006-08-02 00:53 ` Dave Cramer <pg@fastcrypt.com>
2006-08-02 03:06 ` Guy Rouillier <guyr@masergy.com>
2006-08-02 03:34 ` Oliver Jowett <oliver@opencloud.com>

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