pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Set readonly transaction per transaction
8+ messages / 3 participants
[nested] [flat]

* Set readonly transaction per transaction
@ 2014-12-04 10:47  Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Alexandor84 @ 2014-12-04 10:47 UTC (permalink / raw)
  To: pgsql-jdbc

Hi All,

I found that JDBC driver set readOnly transaction as: SET SESSION
CHARACTERISTICS AS TRANSACTION READ ONLY

Is there a way to reconfigure JDBC driver to set ReadOnly like:
BEGIN TRANSACTION READ ONLY;
.
.
COMMIT;

Thank you in advance,
Alex



--
View this message in context: http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-04 10:58  Dave Cramer <pg@fastcrypt.com>
  parent: Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Dave Cramer @ 2014-12-04 10:58 UTC (permalink / raw)
  To: Alexandor84 <oleksandr.sukhotskyi@gmail.com>; +Cc: pgsql-jdbc

Currently no, there is no way to do this.

can you describe your use case ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 4 December 2014 at 05:47, Alexandor84 <oleksandr.sukhotskyi@gmail.com>
wrote:

> Hi All,
>
> I found that JDBC driver set readOnly transaction as: SET SESSION
> CHARACTERISTICS AS TRANSACTION READ ONLY
>
> Is there a way to reconfigure JDBC driver to set ReadOnly like:
> BEGIN TRANSACTION READ ONLY;
> .
> .
> COMMIT;
>
> Thank you in advance,
> Alex
>
>
>
> --
> View this message in context:
> http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-04 11:04  Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Alexandor84 @ 2014-12-04 11:04 UTC (permalink / raw)
  To: pgsql-jdbc

I use PgBouncer in "transaction" mode and it is not compatible with using
mentioned SET statements.

Alex



--
View this message in context: http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205p5829208.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-08 08:17  Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  parent: Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Alexandor84 @ 2014-12-08 08:17 UTC (permalink / raw)
  To: pgsql-jdbc

No one faced with such problem?



--
View this message in context: http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205p5829583.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-08 10:51  Dave Cramer <pg@fastcrypt.com>
  parent: Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Dave Cramer @ 2014-12-08 10:51 UTC (permalink / raw)
  To: Alexandor84 <oleksandr.sukhotskyi@gmail.com>; +Cc: pgsql-jdbc

Apparently not. I doubt many people use pgbouncer in transaction mode.

Can you explain why you are using transaction mode ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 8 December 2014 at 03:17, Alexandor84 <oleksandr.sukhotskyi@gmail.com>
wrote:

> No one faced with such problem?
>
>
>
> --
> View this message in context:
> http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205p5829583.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-09 19:40  Kevin Grittner <kgrittn@ymail.com>
  parent: Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Kevin Grittner @ 2014-12-09 19:40 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; Alexandor84 <oleksandr.sukhotskyi@gmail.com>; +Cc: pgsql-jdbc

Dave Cramer <pg@fastcrypt.com> wrote:
> On 8 December 2014 at 03:17, Alexandor84 <oleksandr.sukhotskyi@gmail.com> wrote:

>> No one faced with such problem?

> Apparently not. I doubt many people use pgbouncer in transaction 
> mode.
>
> Can you explain why you are using transaction mode ?

Hey, now!  I often recommend transaction mode, because I have seen 
applications scale to a much higher concurrency that way.  See:

https://wiki.postgresql.org/wiki/Number_Of_Database_Connections

and:

http://stackoverflow.com/questions/10419665/how-does-pgbouncer-help-to-speed-up-django/10420469#1042...

As a suggestion to the original poster, how about executing:

SET read_only = on;

... as the first statement of a new transaction?

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-10 08:24  Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  parent: Kevin Grittner <kgrittn@ymail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Alexandor84 @ 2014-12-10 08:24 UTC (permalink / raw)
  To: pgsql-jdbc

Hi Kevin,

Thank you for the info.
AFAIK PgBouncer in transaction mode is not compatible with any  SET
<https://wiki.postgresql.org/wiki/PgBouncer;   statements.

Alex



--
View this message in context: http://postgresql.nabble.com/Set-readonly-transaction-per-transaction-tp5829205p5829891.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Set readonly transaction per transaction
@ 2014-12-10 15:37  Kevin Grittner <kgrittn@ymail.com>
  parent: Alexandor84 <oleksandr.sukhotskyi@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Kevin Grittner @ 2014-12-10 15:37 UTC (permalink / raw)
  To: Alexandor84 <oleksandr.sukhotskyi@gmail.com>; pgsql-jdbc

Alexandor84 <oleksandr.sukhotskyi@gmail.com> wrote:


> AFAIK PgBouncer in transaction mode is not compatible with any
> SET statements.

It is compatible with any SET statements which don't leave a
persistent state beyond the end of the transaction.  That includes
any SET LOCAL as well as a few SET options which only affect the
current transaction, like transaction_isolation,
transaction_read_only, and transaction_deferrable (note that these
three have a default_* setting which persists beyond transaction
boundaries -- those defaults are *not* safe to use).

For example, running through pgbouncer configured for transaction
mode:

test=# show transaction_read_only;
transaction_read_only
-----------------------
off
(1 row)

test=# begin;
BEGIN
test=# set transaction_read_only = on;
SET
test=# show transaction_read_only;
transaction_read_only
-----------------------
on
(1 row)

test=# select count(*) from pg_class;
count
-------
299
(1 row)

test=# commit;
COMMIT
test=# show transaction_read_only;
transaction_read_only
-----------------------
off
(1 row)

There's probably some room for improvements in the pgbouncer
documentation on this point.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2014-12-10 15:37 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-12-04 10:47 Set readonly transaction per transaction Alexandor84 <oleksandr.sukhotskyi@gmail.com>
2014-12-04 10:58 ` Dave Cramer <pg@fastcrypt.com>
2014-12-04 11:04   ` Alexandor84 <oleksandr.sukhotskyi@gmail.com>
2014-12-08 08:17     ` Alexandor84 <oleksandr.sukhotskyi@gmail.com>
2014-12-08 10:51       ` Dave Cramer <pg@fastcrypt.com>
2014-12-09 19:40         ` Kevin Grittner <kgrittn@ymail.com>
2014-12-10 08:24           ` Alexandor84 <oleksandr.sukhotskyi@gmail.com>
2014-12-10 15:37             ` Kevin Grittner <kgrittn@ymail.com>

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