Re: Slow statement when using JDBC

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: "vjai(dot)krishnan" <vijay(dot)kanbu(at)gmail(dot)com>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Slow statement when using JDBC
Date: 2014-07-21 14:42:21
Message-ID: CADK3HHJZMVPDgLRuSyJObxO80YnSf6z=9Cf5Kth4bg4fbsrqLQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi Vijay,

Can you show me how you time this ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 21 July 2014 09:29, vjai.krishnan <vijay(dot)kanbu(at)gmail(dot)com> wrote:

> Hi Dave,
>
> Thanks for your reply. I am using postgresql jdbc driver. Here
> is my code that executes the query
>
> *Class.forName("org.postgresql.Driver");
> String pConnectionStr =
> "jdbc:postgresql://localhost:5432/mydb";
> conn = DriverManager.getConnection(pConnectionStr);
> String sql = "select place_id, (select count(*) from (select
> unnest(ARRAY[5098092,10799979,7470935,10799979,5957205,23663129]) INTERSECT
> select unnest(nameaddress_vector))s) as exactmatch from search_name where
> name_vector @> ARRAY[4784827] and nameaddress_vector @>
> ARRAY[17247,202321,10250,7791183,1099136,63895,202321,46909,23663130] order
> by (case when importance = 0 OR importance IS NULL then
> 0.75-(search_rank::float/40) else importance end) DESC, exactmatch DESC
> limit 2";
> stmt = conn.createStatement();
> stmt.executeQuery(sql)*;
>
> The above query takes 440ms in jdbc connection. But when i
> execute the same query in psql client,it takes only 210ms.
>
> Regards,
> Vijay K
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/Slow-statement-when-using-JDBC-tp3368379p5812199.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Wall 2014-07-22 01:14:00 DriverManager.registerDriver - registers twice?
Previous Message vjai.krishnan 2014-07-21 13:29:54 Re: Slow statement when using JDBC