pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jon Leighton <j@jonathanleighton.com>
To: pgsql-performance@postgresql.org
Subject: Cost of opening and closing an empty transaction
Date: Fri, 21 Sep 2012 11:46:58 +0100
Message-ID: <505C45A2.1080601@jonathanleighton.com> (raw)

Hello!

I'm one of the developers of the Ruby on Rails web framework.

In some situations, the framework generates an empty transaction block.
I.e. we sent a BEGIN and then later a COMMIT, with no other queries in
the middle.

We currently can't avoid doing this, because a user *may* send queries
inside the transaction.

I am considering the possibility of making the transaction lazy. So we
would delay sending the BEGIN until we have the first query ready to go.
If that query never comes then neither BEGIN nor COMMIT would ever be sent.

So my question is: is this a worthwhile optimisation to make? In
particular, I am wondering whether empty transactions increase the work
the database has to do when there are several other connections open?
I.e. does it cause contention?

If anyone has any insight about other database servers that would also
be welcome.

Thanks!

Jon Leighton

-- 
http://jonathanleighton.com/




view thread (4+ messages)  latest in thread

Message-ID: <505C45A2.1080601@jonathanleighton.com>
Permalink:  ../505C45A2.1080601@jonathanleighton.com/
Also on:    postgresql.org/message-id/505C45A2.1080601@jonathanleighton.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: j@jonathanleighton.com
  Subject: Re: Cost of opening and closing an empty transaction
  In-Reply-To: <505C45A2.1080601@jonathanleighton.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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