Re: SearchSysCache() tutorial?

From: Andres Freund <andres(at)anarazel(dot)de>
To: Paul Ramsey <pramsey(at)cleverelephant(dot)ca>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: SearchSysCache() tutorial?
Date: 2017-12-11 20:55:54
Message-ID: 20171211205554.6wepaqy4fdu4xxos@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2017-12-11 12:48:27 -0800, Paul Ramsey wrote:
>
> > On Dec 11, 2017, at 12:40 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> >
> > On 2017-12-11 11:26:51 -0800, Paul Ramsey wrote:
> >> On Mon, Dec 11, 2017 at 11:25 AM, Paul Ramsey <pramsey(at)cleverelephant(dot)ca> wrote:
> >>> Is there anywhere any documentation on SearchSysCache? I find I end up
> >>> on these long spelunking expeditions through the code base for a
> >>> particular problem, find the answer after many hours, then forget
> >>> everything I learned because I don't exercise my knowledge frequently
> >>> enough. A decent reference guide would help a lot. What do the various
> >>> SysCacheIdentifier numbers mean/search, some examples, of usage, etc,
> >>> etc.
> >>>
> >>> I can accept if there are not, but it would be a shame to keep on
> >>> hunting like this if there were a good reference lying around.
> >>
> >> My particular hunt today is "for a given table relation, find any
> >> indexes that use the gist access method and are on a single attribute
> >> of type geometry".
> >
> > I don't think there's a way to do this with a single syscache, there
> > won't be an index than can cover all of these. I'd suggest using
> > RelationGetIndexList(), and then filtering for gist and attribute type
> > on the returned value.
>
> Thanks, A, I seem to be on the right path then. Loop through all
> indexes in RelationGetIndexList(), for those that have a relam ==
> GIST_AM_OID, loop through the associated columns (looks like I
> actually have to use a SysScanDesc on AttributeRelationId) and look
> for atts that have the type I’m interested in, and if I find one, yay,
> we have a winner.

Depending on what you do, it might not be a bad idea to do an
index_open() on the oid. The returned Relation entry will already have
looked up the relevant types, and you possibly want to lock anyway...

Greetings,

Andres Freund

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Devrim Gündüz 2017-12-11 23:38:11 Re: Unsigned RPM's ?
Previous Message Paul Ramsey 2017-12-11 20:48:27 Re: SearchSysCache() tutorial?