Re: Partial index locks

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thom Brown <thom(at)linux(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Partial index locks
Date: 2014-03-22 05:32:32
Message-ID: 5324.1395466352@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thom Brown <thom(at)linux(dot)com> writes:
> Is it necessary for a partial index that doesn't include the row to be
> involved in locking?

Yes. You can't determine whether the index needs to get a new entry
without examining its metadata, and that's what the lock is mainly about.

The only possible alternative would be to take the minimum possible
lock (AccessShareLock) on each index so its metadata would hold still,
and then upgrade that to RowExclusiveLock on the one(s) we find need
insertions. This is not better; it means *more* lock management traffic
not less, and lock upgrades increase the potential for deadlocks.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-03-22 06:32:45 Re: Patch for CREATE RULE sgml -- Was in: [DOCS]
Previous Message Jaime Casanova 2014-03-22 02:18:45 Re: Patch for CREATE RULE sgml -- Was in: [DOCS]