Re: Get info about the index

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Igor Korot <ikorot01(at)gmail(dot)com>, Christophe Pettus <xof(at)thebuild(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Get info about the index
Date: 2025-07-26 19:50:20
Message-ID: ece22f937c7240b2c8e54b5c1bf0b46ec8db1db8.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 2025-07-26 at 15:13 -0400, Igor Korot wrote:
> On Sat, Jul 26, 2025, 2:14 PM Christophe Pettus <xof(at)thebuild(dot)com> wrote:
> > > I want to know all individual things:
> > > - whether the index is unique.
> > > - what type of index it is
> > > - whether the field is ASC or DESC.
> > > - all other individual arams
> >
> > pg_index is the source for those.  The one exception is the access method for the index, which is in pg_class.
>
> I didn't find the sorting for the field.

That's in pg_index.indoption.

The flags stored there are defined in src/include/catalog/pg_index.h

/*
* Index AMs that support ordered scans must support these two indoption
* bits. Otherwise, the content of the per-column indoption fields is
* open for future definition.
*/
#define INDOPTION_DESC 0x0001 /* values are in reverse order */
#define INDOPTION_NULLS_FIRST 0x0002 /* NULLs are first instead of last */

So a value of 3 would mean DESC NULLS FIRST.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jon Zeppieri 2025-07-26 19:50:53 Re: Get info about the index
Previous Message Igor Korot 2025-07-26 19:13:23 Re: Get info about the index