Re: Maintaining cluster order on insert

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jaime Casanova <systemguards(at)gmail(dot)com>, "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Maintaining cluster order on insert
Date: 2007-05-18 15:19:18
Message-ID: 464DC3F6.502@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> Heikki Linnakangas <heikki(at)enterprisedb(dot)com> writes:
>> The beef of the patch is two new optional indexam API functions:
>> amprepareinsert and amfinishinsert. amprepareinsert is called before
>> inserting the heap tuple. It descends the tree and finds and pins the
>> right leaf page to insert to, and returns a suggestion on where the heap
>> tuple should be inserted. amfinishinsert is called after inserting the
>> heap tuple to actually insert the index tuple. Documentation for these
>> functions need to be added indexam.sgml, I noticed that that's not done yet.
>
> What happens when there's more than one index?

You can only cluster a table on one index. The other index inserts will
use the aminsert-function, after inserting the heap tuple as usual.

> Is there a risk of deadlock during concurrent insertions (from different
> processes trying to lock the same buffers in different orders)?

No, should be ok. btprepareinsert function will release locks (but not
the pin) after descending the tree, and btfinishinsert will reacquire
them. The locking order is the same as today.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2007-05-18 15:43:49 Re: UTF8MatchText
Previous Message Tom Lane 2007-05-18 15:08:26 Re: Maintaining cluster order on insert

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2007-05-18 15:43:49 Re: UTF8MatchText
Previous Message Tom Lane 2007-05-18 15:08:26 Re: Maintaining cluster order on insert