public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Get info about the index
2+ messages / 2 participants
[nested] [flat]

* Re: Get info about the index
@ 2025-08-02 00:06  Igor Korot <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Igor Korot @ 2025-08-02 00:06 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: David Barbour <[email protected]>; Jon Zeppieri <[email protected]>; Christophe Pettus <[email protected]>; Adrian Klaver <[email protected]>; pgsql-generallists.postgresql.org <[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






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Get info about the index
@ 2025-08-02 00:13  Adrian Klaver <[email protected]>
  parent: Igor Korot <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Adrian Klaver @ 2025-08-02 00:13 UTC (permalink / raw)
  To: Igor Korot <[email protected]>; Laurenz Albe <[email protected]>; +Cc: David Barbour <[email protected]>; Jon Zeppieri <[email protected]>; Christophe Pettus <[email protected]>; pgsql-generallists.postgresql.org <[email protected]>

On 8/1/25 17:06, Igor Korot wrote:
> Hi, Laurenz,

> 
> 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?

No, it refers to:

https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION

> 
> Thank you.
> 
>>
>> Yours,
>> Laurenz Albe


-- 
Adrian Klaver
[email protected]






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2025-08-02 00:13 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-08-02 00:06 Re: Get info about the index Igor Korot <[email protected]>
2025-08-02 00:13 ` Adrian Klaver <[email protected]>

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