diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 633b5c1..f238643 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -679,7 +679,7 @@ create_plain_partial_paths(PlannerInfo *root, RelOptInfo *rel)
 {
 	int			parallel_workers;
 
-	parallel_workers = compute_parallel_worker(rel, rel->pages, 0);
+	parallel_workers = compute_parallel_worker(rel, rel->pages, -1);
 
 	/* If any limit was set to zero, the user doesn't want a parallel scan. */
 	if (parallel_workers <= 0)
@@ -2880,16 +2880,16 @@ remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel)
  * be scanned and the size of the index to be scanned, then choose a minimum
  * of those.
  *
- * "heap_pages" is the number of pages from the table that we expect to scan.
- * "index_pages" is the number of pages from the index that we expect to scan.
+ * "heap_pages" is the number of pages from the table that we expect to scan, or
+ * -1 if we don't expect to scan any.
+ *
+ * "index_pages" is the number of pages from the index that we expect to scan, or
+ * -1 if we don't expect to scan any.
  */
 int
-compute_parallel_worker(RelOptInfo *rel, BlockNumber heap_pages,
-						BlockNumber index_pages)
+compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages)
 {
 	int			parallel_workers = 0;
-	int			heap_parallel_workers = 1;
-	int			index_parallel_workers = 1;
 
 	/*
 	 * If the user has set the parallel_workers reloption, use that; otherwise
@@ -2899,23 +2899,23 @@ compute_parallel_worker(RelOptInfo *rel, BlockNumber heap_pages,
 		parallel_workers = rel->rel_parallel_workers;
 	else
 	{
-		int			heap_parallel_threshold;
-		int			index_parallel_threshold;
-
 		/*
-		 * If this relation is too small to be worth a parallel scan, just
-		 * return without doing anything ... unless it's an inheritance child.
+		 * If too few pages are being justified to make a parallel scan worthwhile,
+		 * just return zero ... unless it's an inheritance child.
 		 * In that case, we want to generate a parallel path here anyway.  It
 		 * might not be worthwhile just for this relation, but when combined
 		 * with all of its inheritance siblings it may well pay off.
 		 */
-		if (heap_pages < (BlockNumber) min_parallel_table_scan_size &&
-			index_pages < (BlockNumber) min_parallel_index_scan_size &&
-			rel->reloptkind == RELOPT_BASEREL)
+		if (rel->reloptkind == RELOPT_BASEREL &&
+			((heap_pages >= 0 && heap_pages < min_parallel_table_scan_size) ||
+			(index_pages >= 0 && index_pages < min_parallel_index_scan_size)))
 			return 0;
 
-		if (heap_pages > 0)
+		if (heap_pages >= 0)
 		{
+			int		heap_parallel_threshold;
+			int		heap_parallel_workers = 1;
+
 			/*
 			 * Select the number of workers based on the log of the size of
 			 * the relation.  This probably needs to be a good deal more
@@ -2935,8 +2935,11 @@ compute_parallel_worker(RelOptInfo *rel, BlockNumber heap_pages,
 			parallel_workers = heap_parallel_workers;
 		}
 
-		if (index_pages > 0)
+		if (index_pages >= 0)
 		{
+			int		index_parallel_workers = 1;
+			int		index_parallel_threshold;
+
 			/* same calculation as for heap_pages above */
 			index_parallel_threshold = Max(min_parallel_index_scan_size, 1);
 			while (index_pages >= (BlockNumber) (index_parallel_threshold * 3))
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
index c138f57..3be7382 100644
--- a/src/backend/optimizer/path/costsize.c
+++ b/src/backend/optimizer/path/costsize.c
@@ -601,8 +601,7 @@ cost_index(IndexPath *path, PlannerInfo *root, double loop_count,
 		 * order.
 		 */
 		path->path.parallel_workers = compute_parallel_worker(baserel,
-											   (BlockNumber) rand_heap_pages,
-												  (BlockNumber) index_pages);
+											   rand_heap_pages, index_pages);
 
 		/*
 		 * Fall out if workers can't be assigned for parallel scan, because in
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index ebda308..f26c6ae 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -54,8 +54,8 @@ extern RelOptInfo *standard_join_search(PlannerInfo *root, int levels_needed,
 					 List *initial_rels);
 
 extern void generate_gather_paths(PlannerInfo *root, RelOptInfo *rel);
-extern int compute_parallel_worker(RelOptInfo *rel, BlockNumber heap_pages,
-						BlockNumber index_pages);
+extern int compute_parallel_worker(RelOptInfo *rel, double heap_pages,
+						double index_pages);
 
 #ifdef OPTIMIZER_DEBUG
 extern void debug_print_rel(PlannerInfo *root, RelOptInfo *rel);
