diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 477b9f7fb8..866c801c55 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -147,6 +147,7 @@ make_one_rel(PlannerInfo *root, List *joinlist)
 {
 	RelOptInfo *rel;
 	Index		rti;
+	double		total_pages;
 
 	/*
 	 * Construct the all_baserels Relids set.
@@ -177,6 +178,40 @@ make_one_rel(PlannerInfo *root, List *joinlist)
 	 * then generate access paths.
 	 */
 	set_base_rel_sizes(root);
+
+	/*
+	 * We should now have size estimates for every actual table involved in
+	 * the query, and we also know which if any have been deleted from the
+	 * query by join removal, pruned by partition pruning, and eliminated by
+	 * constraint exclusion.  We can now compute total_table_pages.
+	 *
+	 * Note that appendrels are not double-counted here, even though we don't
+	 * bother to distinguish RelOptInfos for appendrel parents, because the
+	 * parents will still have size zero.
+	 *
+	 * XXX if a table is self-joined, we will count it once per appearance,
+	 * which perhaps is the wrong thing ... but that's not completely clear,
+	 * and detecting self-joins here is difficult, so ignore it for now.
+	 */
+	total_pages = 0;
+	for (rti = 1; rti < root->simple_rel_array_size; rti++)
+	{
+		RelOptInfo *rel = root->simple_rel_array[rti];
+
+		if (rel == NULL)
+			continue;
+
+		Assert(rel->relid == rti); /* sanity check on array */
+
+		if (IS_DUMMY_REL(rel))
+			continue;
+
+		if (IS_SIMPLE_REL(rel))
+			total_pages += (double) rel->pages;
+	}
+
+	root->total_table_pages = total_pages;
+
 	set_base_rel_pathlists(root);
 
 	/*
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c
index 7a34abca04..41c9d6fcc7 100644
--- a/src/backend/optimizer/plan/planmain.c
+++ b/src/backend/optimizer/plan/planmain.c
@@ -57,8 +57,6 @@ query_planner(PlannerInfo *root, List *tlist,
 	Query	   *parse = root->parse;
 	List	   *joinlist;
 	RelOptInfo *final_rel;
-	Index		rti;
-	double		total_pages;
 
 	/*
 	 * If the query has an empty join tree, then it's something easy like
@@ -225,34 +223,6 @@ query_planner(PlannerInfo *root, List *tlist,
 	 */
 	extract_restriction_or_clauses(root);
 
-	/*
-	 * We should now have size estimates for every actual table involved in
-	 * the query, and we also know which if any have been deleted from the
-	 * query by join removal; so we can compute total_table_pages.
-	 *
-	 * Note that appendrels are not double-counted here, even though we don't
-	 * bother to distinguish RelOptInfos for appendrel parents, because the
-	 * parents will still have size zero.
-	 *
-	 * XXX if a table is self-joined, we will count it once per appearance,
-	 * which perhaps is the wrong thing ... but that's not completely clear,
-	 * and detecting self-joins here is difficult, so ignore it for now.
-	 */
-	total_pages = 0;
-	for (rti = 1; rti < root->simple_rel_array_size; rti++)
-	{
-		RelOptInfo *brel = root->simple_rel_array[rti];
-
-		if (brel == NULL)
-			continue;
-
-		Assert(brel->relid == rti); /* sanity check on array */
-
-		if (IS_SIMPLE_REL(brel))
-			total_pages += (double) brel->pages;
-	}
-	root->total_table_pages = total_pages;
-
 	/*
 	 * Ready to do the primary planning.
 	 */
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 4ad1f8f8b4..fc24a5da46 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -478,9 +478,10 @@ EOF
 	foreach my $bki (@bki_srcs, @bki_data)
 	{
 		next if $bki eq "";
-		if (IsNewer(
-				'src/backend/catalog/bki-stamp',
-				"src/include/catalog/$bki"))
+		if ( 1 #IsNewer(
+				#'src/backend/catalog/bki-stamp',
+				#"src/include/catalog/$bki")
+				)
 		{
 			$need_genbki = 1;
 			last;
