Teach ANALYZE to clear pg_class.relhassubclass when appropriate.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Sep 2011 18:29:31 +0000 (14:29 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Sep 2011 18:29:31 +0000 (14:29 -0400)
commit5b562644fec696977df4a82790064e8287927891
tree3f8132a4e7e9fb9591c3e7f069035388918ae020
parent2f72d5df6a876406cf5f2f8d7800d591dff3e2e3
Teach ANALYZE to clear pg_class.relhassubclass when appropriate.

In the past, relhassubclass always remained true if a relation had ever had
child relations, even if the last subclass was long gone.  While this had
only marginal performance implications in most cases, it was annoying, and
I'm now considering some planner changes that would raise the cost of a
false positive.  It was previously impractical to fix this because of race
condition concerns.  However, given the recent change that made tablecmds.c
take ShareExclusiveLock on relations that are gaining a child (commit
fbcf4b92aa64d4577bcf25925b055316b978744a), we can now allow ANALYZE to
clear the flag when it's no longer relevant.  There is no additional
locking cost to do so, since ANALYZE takes ShareExclusiveLock anyway.
src/backend/catalog/pg_inherits.c
src/backend/commands/analyze.c
src/backend/commands/tablecmds.c
src/include/commands/tablecmds.h