public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Igor Korot <[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: Tue, 29 Jul 2025 14:07:25 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+FnnTyFwR_Xk8pEhasG7GGWAzFk9e4tCBdX36G6H1-=uJxrfg@mail.gmail.com>
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>

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)

Yours,
Laurenz Albe






view thread (11+ 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: <[email protected]>

* 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