Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: index_is_partial(), index_partial_clause_is() #334

Open
halostatue opened this issue Mar 22, 2024 · 0 comments
Open

Feature: index_is_partial(), index_partial_clause_is() #334

halostatue opened this issue Mar 22, 2024 · 0 comments

Comments

@halostatue
Copy link

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants