]> granicus.if.org Git - postgresql/commitdiff
Round rowcount estimate for a partial path to an integer.
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 3 Jul 2016 18:53:37 +0000 (14:53 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 3 Jul 2016 18:53:46 +0000 (14:53 -0400)
I'd been wondering why I was sometimes seeing fractional rowcount
estimates in parallel-query situations, and this seems to be the
reason.  (You won't see the fractional parts in EXPLAIN, because it
prints rowcounts with %.0f, but they are apparent in the debugger.)
A fractional rowcount is not any saner for a partial path than any
other kind of path, and it's equally likely to break cost estimation
for higher paths, so apply clamp_row_est() like we do in other places.

src/backend/optimizer/path/costsize.c

index c4422fe9860a4e21f97be27e71991e64fcad5ebd..1c20edcdfeb2a348dd8cce66f19c0320d8bc9247 100644 (file)
@@ -263,7 +263,7 @@ cost_seqscan(Path *path, PlannerInfo *root,
                 * because they'll anticipate receiving more rows than any given copy
                 * will actually get.
                 */
-               path->rows /= parallel_divisor;
+               path->rows = clamp_row_est(path->rows / parallel_divisor);
 
                /* The CPU cost is divided among all the workers. */
                cpu_run_cost /= parallel_divisor;