Re: update functions locking tables

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: update functions locking tables
Date: 2005-08-30 12:53:41
Message-ID: 20050830125341.GA56245@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Aug 30, 2005 at 08:39:52AM -0300, Clodoaldo Pinto wrote:
>
> begin;
> select update_last_date();
> truncate times_producao;

TRUNCATE acquires an AccessExclusiveLock, which conflicts with all
other lock types. Locks are held until the transaction completes,
so once this lock is acquired no other transactions will be able
to access the table until this transaction commits or rolls back.

DELETE is slower than TRUNCATE but it won't block readers in other
transactions.

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Clodoaldo Pinto 2005-08-30 13:01:53 Re: update functions locking tables
Previous Message Reid Thompson 2005-08-30 12:49:40 Re: Select gives the wrong results