Re: prepared statement performance - Mailing list pgsql-jdbc

From Barry Lind
Subject Re: prepared statement performance
Date
Msg-id 3B4A5A79.1060601@xythos.com
Whole thread Raw
In response to prepared statement performance  (Sheer El-Showk <sheer@saraf.com>)
List pgsql-jdbc
Sheer,

If your code only runs against PostgreSQL, then the answer is that it
wouldn't be worth your time.  The FE/BE protocol that the postgres JDBC
driver uses doesn't support binding variables, so the JDBC driver ends
up doing exactly what you are currently doing in your code, and builds
up a single string from all the values and sends the result to the
server.  If your code also runs against other databases (for example
Oracle) then you could expect to see performance improvements as other
databases may (Oracle does) cache statements and rebind/reexecute.

thanks,
--Barry

Sheer El-Showk wrote:

> Does anyone have some handy metrics of the performance advantage of
> prepared vs unprepared statements?  I'm considering the case of an
> application which has to make multiple queries/inserts (30-100) per
> application transaction and which is currenlty generating the sql by
> building the strings on the fly then passing them to the JDBC.  Can I
> expect significant (ie worth the recoding time) performance increases by
> converting the statements into prepared statements?
>
> Thanks,
> Sheer
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
>



pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: Too much data received?
Next
From: Steve Wampler
Date:
Subject: Re: Too much data received?