Re: Slow statement when using JDBC - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Slow statement when using JDBC
Date
Msg-id CADK3HHJZMVPDgLRuSyJObxO80YnSf6z=9Cf5Kth4bg4fbsrqLQ@mail.gmail.com
Whole thread Raw
In response to Re: Slow statement when using JDBC  ("vjai.krishnan" <vijay.kanbu@gmail.com>)
Responses Re: Slow statement when using JDBC
List 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.kanbu@gmail.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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

pgsql-jdbc by date:

Previous
From: "vjai.krishnan"
Date:
Subject: Re: Slow statement when using JDBC
Next
From: David Wall
Date:
Subject: DriverManager.registerDriver - registers twice?