From: Radosław Smogura <rsmogura@softperience.eu>
To: pgsql-jdbc@postgresql.org
Cc: Yang Zhang <yanghatespam@gmail.com>
Subject: Re: Any way to *not* use server-side prepared statements in Postgresql?
Date: Tue, 19 Jul 2011 04:45:20 +0200
Message-ID: <201107190445.20906.rsmogura@softperience.eu> (raw)
In-Reply-To: <CAKxBDU9zBWCSe0ds0Vx75dpc_Rogxv2CfBCiQSrFWtrs3BTaAA@mail.gmail.com>
References: <CAKxBDU9zBWCSe0ds0Vx75dpc_Rogxv2CfBCiQSrFWtrs3BTaAA@mail.gmail.com>
Yang Zhang <yanghatespam@gmail.com> Tuesday 19 of July 2011 04:07:05
> In (say) Python, I can issue:
>
> psycopg2.connect(...).cursor().execute("select * from account
> where id='00100000006ONCrAAO'")
>
> which on the server results in the following log entries:
>
> 2011-07-18 18:56:08 PDT LOG: duration: 6.112 ms statement:
> select * from account where id='00100000006ONCrAAO'
>
> However, in Java, issuing:
>
> conn.createStatement().executeQuery("select * from account where
> id = '00100000006ONCrAAO'");
>
> results in:
>
> 2011-07-18 18:44:59 PDT LOG: duration: 4.353 ms parse <unnamed>:
> select * from account where id = '00100000006ONCrAAO'
> 2011-07-18 18:44:59 PDT LOG: duration: 0.230 ms bind <unnamed>:
> select * from account where id = '00100000006ONCrAAO'
> 2011-07-18 18:44:59 PDT LOG: duration: 0.246 ms execute
> <unnamed>: select * from account where id = '00100000006ONCrAAO'
>
> 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
>
> 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 it's
about 1ms, so it's about 16%. Probably your call could be faster if You use
prepared statement, but...
Your call do not use prepared statements, as You even don't asked for those.
It uses extended query protocol which sends query in few "chunks", parse,
bind, execute - this is needed to allow result set fetches.
Regards,
Radosław Smogura
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: rsmogura@softperience.eu, yanghatespam@gmail.com
Subject: Re: Any way to *not* use server-side prepared statements in Postgresql?
In-Reply-To: <201107190445.20906.rsmogura@softperience.eu>
References: <CAKxBDU9zBWCSe0ds0Vx75dpc_Rogxv2CfBCiQSrFWtrs3BTaAA@mail.gmail.com> <201107190445.20906.rsmogura@softperience.eu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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