Re: Question about Idle in TX - Mailing list pgsql-general

From Greg Smith
Subject Re: Question about Idle in TX
Date
Msg-id 4C586E66.7070103@2ndquadrant.com
Whole thread Raw
In response to Question about Idle in TX  (David Kerr <dmk@mr-paradox.net>)
Responses Re: Question about Idle in TX
List pgsql-general
David Kerr wrote:
> I know that "Idle in TXs" can interfere with Vaccums for example, but
> I'm not sure if that's due to them usually having some form of lock on a
> table.
>

Locks aren't the issue.  When you have a transaction open, the database
makes sure it can deliver a consistent view of the database for the
lifetime of that transaction, using MVCC:
http://wiki.postgresql.org/wiki/MVCC

What this means in practice is that VACUUM may stop cleaning up old data
because your open transaction might still need to look at it.  Table
maintenance can grind to a halt when you have one of these long running
transactions.  Dead rows (ones left behind by DELETE or UPDATE) will
stop being recycled, tables will grow, queries will slow down.

If you're running 8.4 or later, there is a significant improvement to
how pessimistic that gets in a typical case.  To quote Alvaro, the
author of that patch:

"I expect to be able to remove dead rows created by transactions that
are no longer in progress, but which started more recently than some
currently-open long-running transaction."

It's still something to be wary of.

--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com   www.2ndQuadrant.us


pgsql-general by date:

Previous
From: John R Pierce
Date:
Subject: Re: Finding the primary key of tables
Next
From: Merlin Moncure
Date:
Subject: Re: Finding the primary key of tables