From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | info(at)2ndquadrant(dot)com |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Decibel!" <decibel(at)decibel(dot)org>, PG Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Change lock requirements for adding a trigger |
Date: | 2008-07-17 01:34:29 |
Message-ID: | 200807170134.m6H1YTr20106@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Added to TODO:
* Reduce locking requirements for creating a trigger
http://archives.postgresql.org/pgsql-hackers/2008-06/msg00635.php
---------------------------------------------------------------------------
Simon Riggs wrote:
>
> On Wed, 2008-06-04 at 16:33 -0400, Tom Lane wrote:
> > Simon Riggs <simon(at)2ndquadrant(dot)com> writes:
> > > We have
> > > * relhasindex (bool) set by CREATE INDEX but not unset by DROP INDEX
> > > * relhasrules (bool)
> > > * reltriggers (int2) set by CREATE and DROP, since its an integer
> >
> > Right.
> >
> > > If CREATE INDEX can take a Share lock and can update pg_class, why would
> > > it not be theoretically possible for CREATE TRIGGER?
> >
> > It's (probably) theoretically possible, if we replace reltriggers with a
> > bool that acts more like relhasindex, ie it's a hint to go look in
> > pg_triggers.
>
> Looking at this area of locking, I've noticed that the locks held by
> CREATE TRIGGER are more of a problem than might be apparent.
>
> * Locks held by CREATE TRIGGER are an issue for trigger-based
> replication systems, where triggers are frequently added and removed to
> various tables.
>
> * ALTER TABLE .. ADD FOREIGN KEY holds an AccessExclusiveveLock on
> *both* referencing and referenced tables. It does this because we must
> add triggers to both tables. So reducing the lock strength required by
> CREATE TRIGGER would also allow a reduction in lock strength for adding
> FKs.
>
> So useful steps will be to
>
> * refactor pg_class code so that CREATE TRIGGER uses an identical
> approach to CREATE INDEX
>
> * reduce lock strength for CREATE TRIGGER and ALTER TABLE ... ADD
> FOREIGN KEY so that it takes a ShareLock during
> ATAddForeignKeyConstraint()
>
> * look at how we can reduce lock strength for other ALTER TABLE
> subcommands. Not sure how yet.
>
> --
> Simon Riggs www.2ndQuadrant.com
> PostgreSQL Training, Services and Support
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
From | Date | Subject | |
---|---|---|---|
Next Message | daveg | 2008-07-17 02:44:07 | Re: pg_dump lock timeout |
Previous Message | Bruce Momjian | 2008-07-17 00:44:36 | Re: .psqlrc output for \pset commands |