From: | Craig Ringer <craig(dot)ringer(at)2ndquadrant(dot)com> |
---|---|
To: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Mahi Gurram <teckymahi(at)gmail(dot)com> |
Subject: | Re: Regarding B-Tree Lookup |
Date: | 2017-05-02 12:16:24 |
Message-ID: | CAMsr+YF9e78Jr_H9+Ft2-0yiP6AM6LXum+sd4e06Sz+=XsOjRQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2 May 2017 7:34 pm, "Michael Paquier" <michael(dot)paquier(at)gmail(dot)com> wrote:
On Tue, May 2, 2017 at 6:12 PM, Mahi Gurram <teckymahi(at)gmail(dot)com> wrote:
> I'm building some custom extension on top of postgres 9.6.1. As part of
> that, I would like to read Heap Tuple directly from my extension using
> Primary Key.
>
> By default, postgres table index(B-Tree) its PrimaryKey(PK). So, i would
> like to get TID by doing a lookup into PK's B-Tree index. Using which i
> could read HeapTuple directly.
Use the heapam and indexam.
There's a handy wrapper for simpler queries in genam. See
systable_beginscsn etc. AFAIK these aren't really restricted to system
tables.
>
> 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.
https://www.postgresql.org/docs/9.6/static/spi.html
SPI is certainly the simplest way.
> Suggesting a postgres extensions which does B-Tree lookup will also helps
> me.
Pglogical has lots of direct heap and index access via genam.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2017-05-02 12:27:52 | Re: logical replication and PANIC during shutdown checkpoint in publisher |
Previous Message | zosrothko | 2017-05-02 12:15:58 | Re: [Proposal]: Extends VisualStudio to automatically precompile EmbeddedSQL |