Skip site navigation (1) Skip section navigation (2)

Cost of opening and closing an empty transaction

From: Jon Leighton <j(at)jonathanleighton(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Cost of opening and closing an empty transaction
Date: 2012-09-21 10:46:58
Message-ID: 505C45A2.1080601@jonathanleighton.com (view raw or flat)
Thread:
Lists: pgsql-performance
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/


Responses

pgsql-performance by date

Next:From: BrandonDate: 2012-09-21 17:08:28
Subject: Query Planner Optimization?
Previous:From: Tom LaneDate: 2012-09-20 16:33:21
Subject: Re: problems with large objects dump

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group