diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 41f4374..f35e680 100644
*** a/src/backend/postmaster/pgstat.c
--- b/src/backend/postmaster/pgstat.c
*************** pgstat_db_requested(Oid databaseid)
*** 5504,5509 ****
--- 5504,5518 ----
  {
  	slist_iter	iter;
  
+ 	/*
+ 	 * If any requests are outstanding at all, we should write the stats for
+ 	 * shared catalogs (the "database" with OID 0).  This ensures that
+ 	 * backends will see up-to-date stats for shared catalogs, even though
+ 	 * they send inquiry messages mentioning only their own DB.
+ 	 */
+ 	if (databaseid == InvalidOid && !slist_is_empty(&last_statrequests))
+ 		return true;
+ 
  	/* Check the databases if they need to refresh the stats. */
  	slist_foreach(iter, &last_statrequests)
  	{
