Skip to content

Feature: index_is_partial(), index_partial_clause_is() #334

Open
@halostatue

Description

@halostatue

It would be useful to be able see if an index is partial and what the clause is.

For index_is_partial, we can get that with:

SELECT x.indpred IS NOT NULL
  FROM pg_catalog.pg_index x
  JOIN pg_catalog.pg_class ct    ON ct.oid = x.indrelid
  JOIN pg_catalog.pg_class ci    ON ci.oid = x.indexrelid
  JOIN pg_catalog.pg_namespace n ON n.oid = ct.relnamespace
 WHERE ct.relname = $table
   AND ci.relname = $index
   AND n.nspname  = $schema;

For index_partial_clause_is, we can get the string for the partial clause as:

SELECT pg_get_expr(x.indpred, x.indrelid)
  FROM pg_catalog.pg_index x
  JOIN pg_catalog.pg_class ct    ON ct.oid = x.indrelid
  JOIN pg_catalog.pg_class ci    ON ci.oid = x.indexrelid
  JOIN pg_catalog.pg_namespace n ON n.oid = ct.relnamespace
 WHERE ct.relname = $table
   AND ci.relname = $index
   AND n.nspname  = $schema;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions