In planner, don't assume that empty parent tables aren't really empty.
In planner, don't assume that empty parent tables aren't really empty.

There's a heuristic in estimate_rel_size() to clamp the minimum size
estimate for a table to 10 pages, unless we can see that vacuum or analyze
has been run (and set relpages to something nonzero, so this will always
happen for a table that's actually empty).  However, it would be better
not to do this for inheritance parent tables, which very commonly are
really empty and can be expected to stay that way.  Per discussion of a
recent pgsql-performance report from Anish Kejariwal.  Also prevent it
from happening for indexes (although this is more in the nature of
documentation, since CREATE INDEX normally initializes relpages to
something nonzero anyway).

Back-patch to 9.0, because the ability to collect statistics across a
whole inheritance tree has improved the planner's estimates to the point
where this relatively small error makes a significant difference.  In the
referenced report, merge or hash joins were incorrectly estimated as
cheaper than a nestloop with inner indexscan on the inherited table.
That was less likely before 9.0 because the lack of inherited stats would
have resulted in a default (and rather pessimistic) estimate of the cost
of a merge or hash join.

adam8157/gpdb,tpostgres-projects/tPostgres,ovr/postgres-xl,ashwinstar/gpdb,arcivanov/postgres-xl,zeroae/postgres-xl,snaga/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,tpostgres-projects/tPostgres,lisakowen/gpdb,50wu/gpdb,techdragon/Postgres-XL,50wu/gpdb,zeroae/postgres-xl,greenplum-db/gpdb,arcivanov/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,50wu/gpdb,greenplum-db/gpdb,zeroae/postgres-xl,tpostgres-projects/tPostgres,xinzweb/gpdb,lisakowen/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,50wu/gpdb,greenplum-db/gpdb,50wu/gpdb,techdragon/Postgres-XL,Postgres-XL/Postgres-XL,lisakowen/gpdb,Postgres-XL/Postgres-XL,jmcatamney/gpdb,ovr/postgres-xl,greenplum-db/gpdb,yazun/postgres-xl,jmcatamney/gpdb,postmind-net/postgres-xl,xinzweb/gpdb,snaga/postgres-xl,oberstet/postgres-xl,yazun/postgres-xl,xinzweb/gpdb,arcivanov/postgres-xl,adam8157/gpdb,Postgres-XL/Postgres-XL,jmcatamney/gpdb,techdragon/Postgres-XL,kmjungersen/PostgresXL,postmind-net/postgres-xl,snaga/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,jmcatamney/gpdb,kmjungersen/PostgresXL,pavanvd/postgres-xl,50wu/gpdb,zeroae/postgres-xl,kmjungersen/PostgresXL,techdragon/Postgres-XL,pavanvd/postgres-xl,yazun/postgres-xl,Postgres-XL/Postgres-XL,pavanvd/postgres-xl,lisakowen/gpdb,pavanvd/postgres-xl,yazun/postgres-xl,oberstet/postgres-xl,lisakowen/gpdb,tpostgres-projects/tPostgres,ashwinstar/gpdb,kmjungersen/PostgresXL,oberstet/postgres-xl,postmind-net/postgres-xl,50wu/gpdb,xinzweb/gpdb,ovr/postgres-xl,techdragon/Postgres-XL,50wu/gpdb,arcivanov/postgres-xl,pavanvd/postgres-xl,adam8157/gpdb,greenplum-db/gpdb,xinzweb/gpdb,xinzweb/gpdb,jmcatamney/gpdb,postmind-net/postgres-xl,adam8157/gpdb,postmind-net/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,arcivanov/postgres-xl,adam8157/gpdb,xinzweb/gpdb,greenplum-db/gpdb,ovr/postgres-xl,kmjungersen/PostgresXL,greenplum-db/gpdb,oberstet/postgres-xl,yazun/postgres-xl,snaga/postgres-xl,zeroae/postgres-xl,jmcatamney/gpdb,adam8157/gpdb,ashwinstar/gpdb,arcivanov/postgres-xl,tpostgres-projects/tPostgres,adam8157/gpdb,Postgres-XL/Postgres-XL,xinzweb/gpdb,ashwinstar/gpdb,ovr/postgres-xl,snaga/postgres-xl