public inbox for [email protected]  
help / color / mirror / Atom feed
From: Igor Korot <[email protected]>
To: Laurenz Albe <[email protected]>
Cc: David Barbour <[email protected]>
Cc: Jon Zeppieri <[email protected]>
Cc: Christophe Pettus <[email protected]>
Cc: Adrian Klaver <[email protected]>
Cc: pgsql-generallists.postgresql.org <[email protected]>
Subject: Re: Get info about the index
Date: Fri, 1 Aug 2025 19:06:13 -0500
Message-ID: <CA+FnnTzA5+78w3UbkQCTd74GPqpB=D=tu0eEccqX9301TTcynQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CA+FnnTw2ouEQKSKzQ_SNo8efWE8wEqjr9Ux-F-wbR+y=Pn6bGg@mail.gmail.com>
	<[email protected]>
	<CA+FnnTyKb0cLp9GF3YENoBZ4LVW3db_RSGR99BPFnA4BZtc8kQ@mail.gmail.com>
	<[email protected]>
	<CA+FnnTy8bdXxFZBmFfm1oNMQLVxL-+UmkX8EecbLB0MehX8gFw@mail.gmail.com>
	<CAKfDxxw=4Vax5Oq0apoAE=RkzNgHwvHzKX1ejE6z7n7_vtGBUQ@mail.gmail.com>
	<CAEMHB2QQpfxjbqbyB6zy+TMv9zf42tavLuYUSxDXgyZEaq46Xg@mail.gmail.com>
	<[email protected]>
	<CA+FnnTyFwR_Xk8pEhasG7GGWAzFk9e4tCBdX36G6H1-=uJxrfg@mail.gmail.com>
	<[email protected]>

Hi, Laurenz,

On Tue, Jul 29, 2025 at 7:07 AM Laurenz Albe <[email protected]> wrote:
>
> On Tue, 2025-07-29 at 06:46 -0500, Igor Korot wrote:
> > SELECT
> >     t.relname AS table_name,
> >     i.relname AS index_name,
> >     a.attname AS column_name
> > FROM
> >     pg_class t,
> >     pg_class i,
> >     pg_index ix,
> >     pg_attribute a
> > WHERE
> >     t.oid = ix.indrelid AND
> >     i.oid = ix.indexrelid AND
> >     a.attrelid = t.oid AND
> >     a.attnum = ANY(ix.indkey) AND
> >     t.relkind = 'r' AND -- 'r' for regular table
> >     t.relname = 'your_table_name' -- Optional: filter by table name
> > ORDER BY
> >     t.relname,
> >     i.relname,
> >     a.attnum;
> >
> > I can build on top of this query, however I have 2 issues:
> >
> > First and most important one - they are filtering by just table name.
> > How can I filter by the fully qualified name - catalog.schema.table?
>
> "catalog" is irrelevant, since PostgreSQL doesn't allow cross-database queries.
>
> To add a filter for the schema, use
>
>    AND t.relnamespace = 'schemaname'::regnamespace
>
> > Second - how cn I get the partial index condition? Either the whole
> > WHERE clause (which I will have to parse)
> > or the broken down one (field, condition {AND|OR} field, condition}?
>
>    SELECT pg_get_expr(ix.indpred, t.oid)

I'm looking at the pg_index table and I see it has:

[quote]
indisexclusion bool

If true, this index supports an exclusion constraint
[/quote]

If I read the docs correctly, this field indicates whether the
WHERE condition is actually present.

Am I right?

Thank you.

>
> Yours,
> Laurenz Albe






view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: Get info about the index
  In-Reply-To: <CA+FnnTzA5+78w3UbkQCTd74GPqpB=D=tu0eEccqX9301TTcynQ@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox