Re: [JDBC] Prepared statement performance...

Bruce Momjian <pgman@candle.pha.pa.us>

From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Aaron Mulder <ammulder@alumni.princeton.edu>
Cc: Dave Cramer <Dave@micro-automation.net>, Peter Kovacs <peter.kovacs@sysdata.siemens.hu>, Barry Lind <barry@xythos.com>, Dmitry Tkach <dmitry@openratings.com>, "pgsql-general@postgresql.org" <pgsql-general@postgresql.org>, "pgsql-jdbc@postgresql.org" <pgsql-jdbc@postgresql.org>
Date: 2002-09-27T16:41:14Z
Lists: pgsql-general
Aaron Mulder wrote:
> Dave, Barry, et al.:
> 
> > Unless of course we were to write a
> > sql parser in the jdbc driver so that we could predetermine which
> > statements should use the prepare mechanism or not.
> 
> 	That's a bit of an exaggeration -- all you need to check in the 
> JDBC driver is whether there's an unescaped ; to see if there's more than 
> one statement, right?  It wouldn't be unreasonable to default to enabling 
> the feature unless there's a ; in the statement (or unless there's a ; 
> with anything but whitespace afterward, if you like) -- it wouldn't even 
> be a disaster to forget escaping and just decide based on a ; in the 
> statement period -- few enough statements have an escaped ; that the 
> suboptimal performance in that case won't matter.

psql does do this by tracking quotes and parens and looking for ';'.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073