Re: get/setReadOnly broken if default_transaction_read_only on - Mailing list pgsql-jdbc

From Kevin Grittner
Subject Re: get/setReadOnly broken if default_transaction_read_only on
Date
Msg-id 4FCF7C210200002500048132@gw.wicourts.gov
Whole thread Raw
In response to get/setReadOnly broken if default_transaction_read_only on  (J Chapman Flack <jflack@math.purdue.edu>)
List pgsql-jdbc
J Chapman Flack <jflack@math.purdue.edu> wrote:

> AbstractJdbc2Connection initializes its readOnly member to a
> hardcoded false instead of to 'show default_transaction_read_only'
> from the backend.

> An application can work around (2) by always calling
> setReadOnly(true);setReadOnly(false); if it wants to write.
> But that's a bit ugly.
>
> The driver could do that too for a quick hack, but it would
> be nice to query the correct value from the backend and use that.

+1

This may become increasingly important as Serializable Snapshot
Isolation becomes more popular.  Read only transactions are
significantly more efficient than read-write transactions at the
serializable transaction isolation level in PostgreSQL version 9.1
or higher.  Since our shop has about 90% read only transactions in
common workloads, we have set some servers to
default_transaction_read_only = on in the configuration file and
only turn it off for those transactions which write (or might need
to write).  It would be nice to drop that workaround for the current
behavior.  It should probably do something similar to what's done
for transaction isolation level on connection.

-Kevin

pgsql-jdbc by date:

Previous
From: J Chapman Flack
Date:
Subject: get/setReadOnly broken if default_transaction_read_only on
Next
From: Craig Ringer
Date:
Subject: Re: get/setReadOnly broken if default_transaction_read_only on