Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X9EkT-0002rU-SC for pgsql-jdbc@arkaria.postgresql.org; Mon, 21 Jul 2014 14:39:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X9EkS-0002az-KV for pgsql-jdbc@arkaria.postgresql.org; Mon, 21 Jul 2014 14:39:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X9DfE-0007sP-5B for pgsql-jdbc@postgresql.org; Mon, 21 Jul 2014 13:30:00 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X9DfA-0007XD-GT for pgsql-jdbc@postgresql.org; Mon, 21 Jul 2014 13:29:58 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1X9Df8-00078M-UE for pgsql-jdbc@postgresql.org; Mon, 21 Jul 2014 06:29:54 -0700 Date: Mon, 21 Jul 2014 06:29:54 -0700 (PDT) From: "vjai.krishnan" To: pgsql-jdbc@postgresql.org Message-ID: <1405949394928-5812199.post@n5.nabble.com> In-Reply-To: References: <1375209154731-5765663.post@n5.nabble.com> <1405919198334-5812163.post@n5.nabble.com> <1405920728079-5812174.post@n5.nabble.com> <1405947845904-5812195.post@n5.nabble.com> Subject: Re: Slow statement when using JDBC MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 3.5 (+++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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