public inbox for [email protected]
help / color / mirror / Atom feedFrom: 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: Tue, 29 Jul 2025 07:18:15 -0500
Message-ID: <CA+FnnTzGZwjg5jJRVwMX_TyRpW+bJZAyN3EFv7qFv56_RfbFjw@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]>
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.
The reason I'm asking this is because I want to have the same
interface for different DBMSes.
But it also made me curious.
If I have a database for some financial data for the year 2024 in the
mydb_2024 and I have current year financial data in the mydb_2025 how
can I compare the data?
>
> 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
Thank you.
view thread (11+ messages)
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+FnnTzGZwjg5jJRVwMX_TyRpW+bJZAyN3EFv7qFv56_RfbFjw@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