Fix a performance problem in databases with large numbers of tables (or other types of pg_class entry): the function pgstat_vacuum_tabstat, invoked during VACUUM startup, had runtime proportional to the number of stats table entries times the number of pg_class rows; in other words O(N^2) if the stats collector's information is reasonably complete. Replace list searching with a hash table to bring it back to O(N) behavior.  Per report from kim at myemma.com.
Fix a performance problem in databases with large numbers of tables
(or other types of pg_class entry): the function pgstat_vacuum_tabstat,
invoked during VACUUM startup, had runtime proportional to the number of
stats table entries times the number of pg_class rows; in other words
O(N^2) if the stats collector's information is reasonably complete.
Replace list searching with a hash table to bring it back to O(N)
behavior.  Per report from kim at myemma.com.

Back-patch as far as 8.1; 8.0 and before use different coding here.

greenplum-db/gpdb,xinzweb/gpdb,foyzur/gpdb,ashwinstar/gpdb,atris/gpdb,kaknikhil/gpdb,edespino/gpdb,50wu/gpdb,rvs/gpdb,0x0FFF/gpdb,ovr/postgres-xl,adam8157/gpdb,rvs/gpdb,cjcjameson/gpdb,foyzur/gpdb,lpetrov-pivotal/gpdb,adam8157/gpdb,rvs/gpdb,tangp3/gpdb,rvs/gpdb,ashwinstar/gpdb,ahachete/gpdb,lpetrov-pivotal/gpdb,lpetrov-pivotal/gpdb,snaga/postgres-xl,postmind-net/postgres-xl,atris/gpdb,arcivanov/postgres-xl,techdragon/Postgres-XL,zaksoup/gpdb,Chibin/gpdb,greenplum-db/gpdb,rubikloud/gpdb,edespino/gpdb,Postgres-XL/Postgres-XL,zeroae/postgres-xl,tpostgres-projects/tPostgres,lintzc/gpdb,randomtask1155/gpdb,Quikling/gpdb,kmjungersen/PostgresXL,chrishajas/gpdb,arcivanov/postgres-xl,foyzur/gpdb,edespino/gpdb,arcivanov/postgres-xl,foyzur/gpdb,tangp3/gpdb,oberstet/postgres-xl,yuanzhao/gpdb,ahachete/gpdb,lintzc/gpdb,yuanzhao/gpdb,janebeckman/gpdb,chrishajas/gpdb,yuanzhao/gpdb,lintzc/gpdb,foyzur/gpdb,Chibin/gpdb,yuanzhao/gpdb,Quikling/gpdb,tangp3/gpdb,CraigHarris/gpdb,zeroae/postgres-xl,arcivanov/postgres-xl,royc1/gpdb,ahachete/gpdb,kaknikhil/gpdb,Chibin/gpdb,atris/gpdb,adam8157/gpdb,pavanvd/postgres-xl,ashwinstar/gpdb,postmind-net/postgres-xl,randomtask1155/gpdb,lisakowen/gpdb,randomtask1155/gpdb,Quikling/gpdb,greenplum-db/gpdb,yuanzhao/gpdb,snaga/postgres-xl,greenplum-db/gpdb,royc1/gpdb,tpostgres-projects/tPostgres,zaksoup/gpdb,Chibin/gpdb,jmcatamney/gpdb,edespino/gpdb,xuegang/gpdb,kmjungersen/PostgresXL,cjcjameson/gpdb,royc1/gpdb,Chibin/gpdb,foyzur/gpdb,xinzweb/gpdb,rubikloud/gpdb,zaksoup/gpdb,techdragon/Postgres-XL,tangp3/gpdb,rvs/gpdb,ashwinstar/gpdb,zeroae/postgres-xl,adam8157/gpdb,atris/gpdb,janebeckman/gpdb,royc1/gpdb,yazun/postgres-xl,janebeckman/gpdb,oberstet/postgres-xl,ahachete/gpdb,atris/gpdb,chrishajas/gpdb,rubikloud/gpdb,ovr/postgres-xl,kmjungersen/PostgresXL,techdragon/Postgres-XL,ashwinstar/gpdb,Postgres-XL/Postgres-XL,xuegang/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,xuegang/gpdb,lisakowen/gpdb,yazun/postgres-xl,50wu/gpdb,0x0FFF/gpdb,kmjungersen/PostgresXL,adam8157/gpdb,snaga/postgres-xl,chrishajas/gpdb,0x0FFF/gpdb,tangp3/gpdb,Postgres-XL/Postgres-XL,xinzweb/gpdb,CraigHarris/gpdb,techdragon/Postgres-XL,zeroae/postgres-xl,royc1/gpdb,yuanzhao/gpdb,randomtask1155/gpdb,lpetrov-pivotal/gpdb,Postgres-XL/Postgres-XL,lintzc/gpdb,0x0FFF/gpdb,ahachete/gpdb,xinzweb/gpdb,xinzweb/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,xinzweb/gpdb,lisakowen/gpdb,rubikloud/gpdb,50wu/gpdb,Quikling/gpdb,0x0FFF/gpdb,Chibin/gpdb,kaknikhil/gpdb,kaknikhil/gpdb,randomtask1155/gpdb,lisakowen/gpdb,kaknikhil/gpdb,chrishajas/gpdb,rvs/gpdb,oberstet/postgres-xl,cjcjameson/gpdb,atris/gpdb,Chibin/gpdb,Quikling/gpdb,rvs/gpdb,cjcjameson/gpdb,CraigHarris/gpdb,arcivanov/postgres-xl,Quikling/gpdb,0x0FFF/gpdb,jmcatamney/gpdb,edespino/gpdb,greenplum-db/gpdb,xinzweb/gpdb,adam8157/gpdb,janebeckman/gpdb,Chibin/gpdb,randomtask1155/gpdb,janebeckman/gpdb,tpostgres-projects/tPostgres,yazun/postgres-xl,janebeckman/gpdb,postmind-net/postgres-xl,jmcatamney/gpdb,lisakowen/gpdb,lpetrov-pivotal/gpdb,cjcjameson/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,kaknikhil/gpdb,jmcatamney/gpdb,adam8157/gpdb,yazun/postgres-xl,CraigHarris/gpdb,edespino/gpdb,0x0FFF/gpdb,cjcjameson/gpdb,CraigHarris/gpdb,tangp3/gpdb,arcivanov/postgres-xl,royc1/gpdb,xuegang/gpdb,postmind-net/postgres-xl,chrishajas/gpdb,kaknikhil/gpdb,rubikloud/gpdb,Quikling/gpdb,snaga/postgres-xl,randomtask1155/gpdb,zaksoup/gpdb,yuanzhao/gpdb,ovr/postgres-xl,lintzc/gpdb,chrishajas/gpdb,ahachete/gpdb,pavanvd/postgres-xl,zeroae/postgres-xl,kmjungersen/PostgresXL,royc1/gpdb,foyzur/gpdb,rubikloud/gpdb,janebeckman/gpdb,ashwinstar/gpdb,yazun/postgres-xl,lpetrov-pivotal/gpdb,lpetrov-pivotal/gpdb,0x0FFF/gpdb,50wu/gpdb,rvs/gpdb,50wu/gpdb,kaknikhil/gpdb,yuanzhao/gpdb,50wu/gpdb,lisakowen/gpdb,cjcjameson/gpdb,rvs/gpdb,cjcjameson/gpdb,snaga/postgres-xl,yuanzhao/gpdb,atris/gpdb,edespino/gpdb,tangp3/gpdb,Chibin/gpdb,edespino/gpdb,CraigHarris/gpdb,xuegang/gpdb,CraigHarris/gpdb,techdragon/Postgres-XL,tpostgres-projects/tPostgres,ovr/postgres-xl,yuanzhao/gpdb,zaksoup/gpdb,lpetrov-pivotal/gpdb,CraigHarris/gpdb,CraigHarris/gpdb,Quikling/gpdb,ovr/postgres-xl,oberstet/postgres-xl,lintzc/gpdb,lintzc/gpdb,Quikling/gpdb,zaksoup/gpdb,ahachete/gpdb,tpostgres-projects/tPostgres,cjcjameson/gpdb,ahachete/gpdb,rubikloud/gpdb,chrishajas/gpdb,janebeckman/gpdb,lisakowen/gpdb,pavanvd/postgres-xl,xuegang/gpdb,adam8157/gpdb,rubikloud/gpdb,randomtask1155/gpdb,foyzur/gpdb,xuegang/gpdb,Postgres-XL/Postgres-XL,cjcjameson/gpdb,kaknikhil/gpdb,50wu/gpdb,janebeckman/gpdb,postmind-net/postgres-xl,ashwinstar/gpdb,50wu/gpdb,xuegang/gpdb,jmcatamney/gpdb,royc1/gpdb,greenplum-db/gpdb,lintzc/gpdb,jmcatamney/gpdb,tangp3/gpdb,lintzc/gpdb,Chibin/gpdb,zaksoup/gpdb,pavanvd/postgres-xl,greenplum-db/gpdb,rvs/gpdb,oberstet/postgres-xl,edespino/gpdb,greenplum-db/gpdb,xuegang/gpdb,edespino/gpdb,zaksoup/gpdb,xinzweb/gpdb,Quikling/gpdb,atris/gpdb,janebeckman/gpdb