[ruby-dbi-users] [dbd_pg] Prepared statement performance

KUBO Takehiro kubo at jiubao.org
Sun Sep 7 10:14:06 EDT 2008

On Sun, Sep 7, 2008 at 4:49 PM, Erik Hollensbe <erik at hollensbe.org> wrote:
> On Sunday 07 September 2008 00:29:05 Erik Hollensbe wrote:
>> On Saturday 06 September 2008 19:05:34 KUBO Takehiro wrote:
>> > But postgresql's SQL statements are not cached automatically. Database
>> > client application must manage it explicitly by a name of the
>> > statement, and it is reused only when the name is reused explicitly.
>> Sounds great, makes perfect sense. Thank you for pointing this out.
>> Performance issues aren't my focus at this point, and if you're willing to
>> tackle them I'm happy to accept patches.

Well sorry, I'm not willing to do it for now. My priority is (1)
ruby-oci8 2.0, which
should be released before ruby 1.9.1, (2) dbd::oci8. In addition I'm not certain
whether the feature should be added to dbd::pg or ruby-pg.

> Oh, I just realized... This may butt heads with the pg_native_binds option,
> which uses server-side bound parameters as well as the prepared statements
> (when it's off, it uses the DBI quoter, which is a little more flexible), so
> if you do end up patching this, you may need to be aware that depending on the
> situation, these options may need to be co-dependent. The majority of the
> relevant code is in lib/dbd/pg/statement.rb.

Yes. Usable combinations are:
1. native binding and server-side prepared statement
2. native binding and prepared statement emulation
3. binding emulation and prepared statement emulation

The next is useless because it can be used only when the bind values are not
changed for each execution.
4. binding emulation and server-side prepared statement

More information about the ruby-dbi-users mailing list