Re: B-tree descend for insertion locking - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: B-tree descend for insertion locking
Date
Msg-id CAA4eK1Jz2j3RKLkUokOAQ9oLHMW7RGBkBB5t7biEJoELq5x24w@mail.gmail.com
Whole thread Raw
In response to B-tree descend for insertion locking  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
On Tue, Mar 18, 2014 at 4:42 PM, Heikki Linnakangas
<hlinnakangas@vmware.com> wrote:
> When inserting into a B-tree index, all the pages are read-locked when
> descending the tree. When we reach the leaf page, the read-lock is exchanged
> for a write-lock.
>
> There's nothing wrong with that, but why don't we just directly grab a
> write-lock on the leaf page? When descending, we know the level we're on,
> and what level the child page is. The only downside I can see is that we
> would unnecessarily hold a write-lock when a read-lock would suffice, if the
> page was just split and we have to move right. But that seems like a really
> bad bet - hitting the page when it was just split is highly unlikely.

Another case could be when the page is half dead or deleted, but again
chances of same are relatively less.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Atri Sharma
Date:
Subject: Re: Planner hints in Postgresql
Next
From: Heikki Linnakangas
Date:
Subject: Re: pg_archivecleanup bug