Re: Regarding B-Tree Lookup

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Mahi Gurram <teckymahi(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Regarding B-Tree Lookup
Date: 2017-05-02 12:29:27
Message-ID: 27992.1493728167@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
> On Tue, May 2, 2017 at 6:12 PM, Mahi Gurram <teckymahi(at)gmail(dot)com> wrote:
>> Please suggest me the easiest way to lookup into PK's B-Tree index for
>> getting TIDs.

> Why don't you just use SPI within your extension? No need to copy the
> logic for btree lookups this way.

There's not actually that much code needed, though -- basically
index_beginscan, index_rescan, index_getnext, index_endscan. One possible
model to follow is systable_beginscan and friends, in genam.c.

I think that you could possibly get away with just applying
systable_beginscan to random user tables, even. But it's at least a
conceptual mismatch, and there are some things in there, like the
test on IgnoreSystemIndexes, that you probably don't want.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2017-05-02 12:30:59 Re: logical replication and PANIC during shutdown checkpoint in publisher
Previous Message Peter Eisentraut 2017-05-02 12:27:52 Re: logical replication and PANIC during shutdown checkpoint in publisher