Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6A4B5B5DBCC for ; Mon, 18 Jul 2011 23:45:25 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 61337-06 for ; Tue, 19 Jul 2011 02:45:18 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.softperience.eu (static-ip-217-118-26-141.inaddr.intergenia.de [217.118.26.141]) by mail.postgresql.org (Postfix) with ESMTP id 7C75AB5D803 for ; Mon, 18 Jul 2011 23:45:17 -0300 (ADT) Received: from radek.localnet (ceg64.neoplus.adsl.tpnet.pl [83.30.182.64]) by mail.softperience.eu (Postfix) with ESMTPA id 32966B96032; Tue, 19 Jul 2011 04:45:18 +0200 (CEST) From: =?utf-8?q?Rados=C5=82aw_Smogura?= To: pgsql-jdbc@postgresql.org Subject: Re: Any way to *not* use server-side prepared statements in Postgresql? Date: Tue, 19 Jul 2011 04:45:20 +0200 User-Agent: KMail/1.13.7 (Linux/2.6.38-gentoo-r6; KDE/4.6.3; x86_64; ; ) Cc: Yang Zhang References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <201107190445.20906.rsmogura@softperience.eu> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.778 tagged_above=-10 required=5 tests=BAYES_00=-1.9, URI_HEX=1.122 X-Spam-Level: X-Archive-Number: 201107/19 X-Sequence-Number: 22023 Yang Zhang Tuesday 19 of July 2011 04:07:05 > In (say) Python, I can issue: >=20 > psycopg2.connect(...).cursor().execute("select * from account > where id=3D'00100000006ONCrAAO'") >=20 > which on the server results in the following log entries: >=20 > 2011-07-18 18:56:08 PDT LOG: duration: 6.112 ms statement: > select * from account where id=3D'00100000006ONCrAAO' >=20 > However, in Java, issuing: >=20 > conn.createStatement().executeQuery("select * from account where > id =3D '00100000006ONCrAAO'"); >=20 > results in: >=20 > 2011-07-18 18:44:59 PDT LOG: duration: 4.353 ms parse : > select * from account where id =3D '00100000006ONCrAAO' > 2011-07-18 18:44:59 PDT LOG: duration: 0.230 ms bind : > select * from account where id =3D '00100000006ONCrAAO' > 2011-07-18 18:44:59 PDT LOG: duration: 0.246 ms execute > : select * from account where id =3D '00100000006ONCrAAO' >=20 > Some searching shows that the PG JDBC driver *always* uses prepared > statements: > http://postgresql.1045698.n5.nabble.com/JDBC-prepared-statements-amp-serve > r-side-prepared-statements-td1919506.html >=20 > Is there any way to circumvent server prepared statements? If it makes > a difference, I'm asking regarding PG 8.4 and 9.0. Thanks in advance. Hi, At the begining it's looks like your Java call is faster then python, and i= t's=20 about 1ms, so it's about 16%. Probably your call could be faster if You use= =20 prepared statement, but... Your call do not use prepared statements, as You even don't asked for those= =2E=20 It uses extended query protocol which sends query in few "chunks", parse,=20 bind, execute - this is needed to allow result set fetches. Regards, Rados=C5=82aw Smogura