aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-03-06 23:47:38 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-03-06 23:48:09 -0500
commit1908abc4a37d397356c9cdf0fd31c33a86281d63 (patch)
tree607be9f8752401246ad57e8b3371e62cf6120180 /src/backend/optimizer
parent97951139164055d6bae5aae7ea058c28e1462253 (diff)
downloadpostgresql-1908abc4a37d397356c9cdf0fd31c33a86281d63.tar.gz
postgresql-1908abc4a37d397356c9cdf0fd31c33a86281d63.zip
Arrange to cache FdwRoutine structs in foreign tables' relcache entries.
This saves several catalog lookups per reference. It's not all that exciting right now, because we'd managed to minimize the number of places that need to fetch the data; but the upcoming writable-foreign-tables patch needs this info in a lot more places.
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/path/allpaths.c3
-rw-r--r--src/backend/optimizer/util/plancat.c8
2 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 0545f958f67..86d5bb71b0a 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -410,9 +410,6 @@ set_foreign_size(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
/* Mark rel with estimated output rows, width, etc */
set_foreign_size_estimates(root, rel);
- /* Get FDW routine pointers for the rel */
- rel->fdwroutine = GetFdwRoutineByRelId(rte->relid);
-
/* Let FDW adjust the size estimates, if it can */
rel->fdwroutine->GetForeignRelSize(root, rel, rte->relid);
}
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index bff7aff593d..954666ce04c 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -26,6 +26,7 @@
#include "access/xlog.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
+#include "foreign/fdwapi.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
@@ -67,6 +68,7 @@ static List *build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
* min_attr lowest valid AttrNumber
* max_attr highest valid AttrNumber
* indexlist list of IndexOptInfos for relation's indexes
+ * fdwroutine if it's a foreign table, the FDW function pointers
* pages number of pages
* tuples number of tuples
*
@@ -374,6 +376,12 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
rel->indexlist = indexinfos;
+ /* Grab the fdwroutine info using the relcache, while we have it */
+ if (relation->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
+ rel->fdwroutine = GetFdwRoutineForRelation(relation, true);
+ else
+ rel->fdwroutine = NULL;
+
heap_close(relation, NoLock);
/*