8

Looking for the view I can list up all 'invalid' objects in PostgreSQL. In Oracle, we can use dab_objects.status column but I'm not sure if there is a simple way to do such a thing in PostgreSQL.

Maybe, I can check the invalid indexes with below code. How can I do that for other objects?

SELECT pg_class.relname 
FROM pg_class, pg_index 
WHERE pg_index.indisvalid = false 
AND pg_index.indexrelid = pg_class.oid;
lospejos
  • 1,976
  • 3
  • 19
  • 35
Sigularity
  • 917
  • 2
  • 12
  • 28

1 Answers1

10

I don't think that you have to check anything else, since other objects cannot become invalid in PostgreSQL.

Oracle and PostgreSQL work quite differently in that respect:

  • In Oracle, you can always ALTER an object (for example a table) even if there are dependent objects (for example views). The dependent objects then become invalid and have to be recompiled.

  • In PostgreSQL, you cannot ALTER an object that has dependend objects in a way that renders these dependent objects invalid. You have to drop and recreate the dependent objects.

Invalid indexes can be left behind by a failed CREATE INDEX command.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263