pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
slow jdbc postgres connection
7+ messages / 4 participants
[nested] [flat]

* slow jdbc postgres connection
@ 2007-04-26 09:19 Stefan Zweig <stefanzweig1881@web.de>
  2007-04-26 10:04 ` Re: slow jdbc postgres connection Heikki Linnakangas <heikki@enterprisedb.com>
  2007-04-26 11:19 ` Re: slow jdbc postgres connection Oliver Jowett <oliver@opencloud.com>
  2007-04-26 12:19 ` Re: slow jdbc postgres connection Oliver Jowett <oliver@opencloud.com>
  0 siblings, 3 replies; 7+ messages in thread

From: Stefan Zweig @ 2007-04-26 09:19 UTC (permalink / raw)
  To: pgsql-jdbc

hi i have the following problem:

when i execute the following query via pgAdminIII i get a result within 31ms

Select version()
result: PostgreSQL 8.1

if try to execute the same query using the jdbc-interface from a java-application the same query needs horrible 4756ms.
my jdbc driver is  8.1-409 JDBC 3
my postgres version is 8.1.8
my JRE-Version: 1.5.0_07

Connection pgconnection = null;

// Load the pgSQL JDBC driver
String pgdriverName = "org.postgresql.Driver";
Class.forName(pgdriverName);

// Create a connection to the "test" database
String pgserverName = "10.100.6.245";
String pgdatabase = "test";
String url = "jdbc:postgresql://" + pgserverName +  "/" + pgdatabase + "?characterEncoding=UTF8&useUnicode=true";
String username = "user";
String password = "password";

pgconnection = DriverManager.getConnection(url, username, password);

ResultSet pgresultSet;
Statement pgstatement;
pgstatement = pgconnection.createStatement();

String pgquery;
pgquery="SELECT version()";
			

long start=System.currentTimeMillis();//start time measurement

pgresultSet = pgstatement.executeQuery(pgquery);

long time=System.currentTimeMillis()-start;//end time measurement

//time =4756ms

pgconnection.close();


if i do the similar query on our mysql database, which is on the same local server, i get quick results, so the reason probably cannot be a slow intranet-connection


any help would be appriciated.


regards. stefan
_______________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192




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

* Re: slow jdbc postgres connection
  2007-04-26 09:19 slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
@ 2007-04-26 10:04 ` Heikki Linnakangas <heikki@enterprisedb.com>
  2007-04-26 10:05   ` Re: slow jdbc postgres connection Heikki Linnakangas <heikki@enterprisedb.com>
  2 siblings, 1 reply; 7+ messages in thread

From: Heikki Linnakangas @ 2007-04-26 10:04 UTC (permalink / raw)
  To: Stefan Zweig <stefanzweig1881@web.de>; +Cc: pgsql-jdbc

Stefan Zweig wrote:
> when i execute the following query via pgAdminIII i get a result within 31ms
> 
> Select version()
> result: PostgreSQL 8.1
> 
> if try to execute the same query using the jdbc-interface from a java-application the same query needs horrible 4756ms.
> my jdbc driver is  8.1-409 JDBC 3
> my postgres version is 8.1.8
> my JRE-Version: 1.5.0_07

Strange. Are you sure the time is spent on executing the query, and not 
on acquiring the connection? What kind of an application is it? There's 
no application server or framework involved? Would you please add 
loglevel=1 to the URL, and post the output? Maybe that will give a clue.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



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

* Re: slow jdbc postgres connection
  2007-04-26 09:19 slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
  2007-04-26 10:04 ` Re: slow jdbc postgres connection Heikki Linnakangas <heikki@enterprisedb.com>
@ 2007-04-26 10:05   ` Heikki Linnakangas <heikki@enterprisedb.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Heikki Linnakangas @ 2007-04-26 10:05 UTC (permalink / raw)
  To: Stefan Zweig <stefanzweig1881@web.de>; +Cc: pgsql-jdbc

I wrote:
> Strange. Are you sure the time is spent on executing the query, and not 
> on acquiring the connection? What kind of an application is it? There's 
> no application server or framework involved? Would you please add 
> loglevel=1 to the URL, and post the output? Maybe that will give a clue.

Actually loglevel=2, that'll give more details..

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



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

* Re: slow jdbc postgres connection
  2007-04-26 09:19 slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
@ 2007-04-26 11:19 ` Oliver Jowett <oliver@opencloud.com>
  2 siblings, 0 replies; 7+ messages in thread

From: Oliver Jowett @ 2007-04-26 11:19 UTC (permalink / raw)
  To: Stefan Zweig <stefanzweig1881@web.de>; +Cc: pgsql-jdbc

Stefan Zweig wrote:

> long start=System.currentTimeMillis();//start time measurement
> 
> pgresultSet = pgstatement.executeQuery(pgquery);
> 
> long time=System.currentTimeMillis()-start;//end time measurement
> 
> //time =4756ms

And if you run the query a second time on the same connection (or even 
on a completely new connection in the same JVM), what's the time for 
that? I'd guess you're measuring mostly classloading costs.

-O




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

* Re: slow jdbc postgres connection
  2007-04-26 09:19 slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
@ 2007-04-26 12:19 ` Oliver Jowett <oliver@opencloud.com>
  2 siblings, 0 replies; 7+ messages in thread

From: Oliver Jowett @ 2007-04-26 12:19 UTC (permalink / raw)
  To: Stefan Zweig <stefanzweig1881@web.de>; +Cc: pgsql-jdbc

Stefan Zweig wrote:

> String url = "jdbc:postgresql://" + pgserverName +  "/" + pgdatabase + "?characterEncoding=UTF8&useUnicode=true";

One other note, the PG driver will not understand (and silently ignores) 
the "characterEncoding" and "useUnicode" URL parameters.. not sure quite 
what you're trying to do there.

-O



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

* Re: slow jdbc postgres connection
@ 2007-04-26 09:43 Stefan Zweig <stefanzweig1881@web.de>
  2007-04-27 01:11 ` Re: slow jdbc postgres connection Craig Servin <cservin@cromagnon.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Stefan Zweig @ 2007-04-26 09:43 UTC (permalink / raw)
  To: pgsql-jdbc

hi,

just to be sure that it cannot be the intranet-connection i tried to run my java test database application directly on the server. mysql-jdbc answered within 20ms pgsql-jdbc needed 5494ms and i have no idea why?

any advices would be appreciated.

regards. stefan
> hi i have the following problem:
>
> when i execute the following query via pgAdminIII i get a result within 31ms
>
> Select version()
> result: PostgreSQL 8.1
>
> if try to execute the same query using the jdbc-interface from a java-application the same query needs horrible 4756ms.
> my jdbc driver is  8.1-409 JDBC 3
> my postgres version is 8.1.8
> my JRE-Version: 1.5.0_07
>
> Connection pgconnection = null;
>
> // Load the pgSQL JDBC driver
> String pgdriverName = "org.postgresql.Driver";
> Class.forName(pgdriverName);
>
> // Create a connection to the "test" database
> String pgserverName = "10.100.6.245";
> String pgdatabase = "test";
> String url = "jdbc:postgresql://" + pgserverName +  "/" + pgdatabase + "?characterEncoding=UTF8&useUnicode=true";
> String username = "user";
> String password = "password";
>
> pgconnection = DriverManager.getConnection(url, username, password);
>
> ResultSet pgresultSet;
> Statement pgstatement;
> pgstatement = pgconnection.createStatement();
>
> String pgquery;
> pgquery="SELECT version()";
> 			
>
> long start=System.currentTimeMillis();//start time measurement
>
> pgresultSet = pgstatement.executeQuery(pgquery);
>
> long time=System.currentTimeMillis()-start;//end time measurement
>
> //time =4756ms
>
> pgconnection.close();
>
>
> if i do the similar query on our mysql database, which is on the same local server, i get quick results, so the reason probably cannot be a slow intranet-connection
>
>
> any help would be appriciated.
>
>
> regards. stefan
> _______________________________________________________________
> SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
> kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


_______________________________________________________________
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192




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

* Re: slow jdbc postgres connection
  2007-04-26 09:43 Re: slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
@ 2007-04-27 01:11 ` Craig Servin <cservin@cromagnon.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Craig Servin @ 2007-04-27 01:11 UTC (permalink / raw)
  To: pgsql-jdbc

Without seeing more of the logging information it is hard to tell what the 
problem may be, but as a sanity check I can tell you that I have never seen a 
5000ms connection time.



On Thursday 26 April 2007 04:43:59 am Stefan Zweig wrote:
> hi,
>
> just to be sure that it cannot be the intranet-connection i tried to run my
> java test database application directly on the server. mysql-jdbc answered
> within 20ms pgsql-jdbc needed 5494ms and i have no idea why?
>
> any advices would be appreciated.



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


end of thread, other threads:[~2007-04-27 01:11 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-26 09:19 slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
2007-04-26 10:04 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-04-26 10:05   ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-04-26 11:19 ` Oliver Jowett <oliver@opencloud.com>
2007-04-26 12:19 ` Oliver Jowett <oliver@opencloud.com>
2007-04-26 09:43 Re: slow jdbc postgres connection Stefan Zweig <stefanzweig1881@web.de>
2007-04-27 01:11 ` Craig Servin <cservin@cromagnon.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