The patch is calculating user mapping when it's readily available through RelOptInfo::fdw_private. That incurs a catalog lookup unnecessarily. Instead, can we add new function makeOid, oidVal on the lines of makeInteger and intVal to store and retrieve an OID resp. and also corresponding print function? It might be helpful in future.
That might be an idea, but is the overhead in that re-calculation so large?
A call to GetForeignTable would incur a catalog lookup which means a catalog table/index scan if corresponding entry is not in the cache. This is followed by GetUserMapping() which is another catalog access. That's bound to be expensive than an makeOid(), oidVal() call.
--
Best Wishes, Ashutosh Bapat EnterpriseDB Corporation The Postgres Database Company