mirror of
https://github.com/postgres/postgres.git
synced 2025-05-31 00:01:57 -04:00
Fix estimates for ModifyTable paths without RETURNING.
In the past, we always estimated that a ModifyTable node would emit the same number of rows as its subpaths. Without a RETURNING clause, the correct estimate is zero. Fix, in preparation for a proposed parallel write patch that is sensitive to that number. A remaining problem is that for RETURNING queries, the estimated width is based on subpath output rather than the RETURNING tlist. Reviewed-by: Greg Nancarrow <gregn4422@gmail.com> Discussion: https://postgr.es/m/CAJcOf-cXnB5cnMKqWEp2E2z7Mvcd04iLVmV%3DqpFJrR3AcrTS3g%40mail.gmail.com
This commit is contained in:
parent
3fb676504d
commit
f0f13a3a08
@ -3583,15 +3583,18 @@ create_modifytable_path(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
if (lc == list_head(subpaths)) /* first node? */
|
if (lc == list_head(subpaths)) /* first node? */
|
||||||
pathnode->path.startup_cost = subpath->startup_cost;
|
pathnode->path.startup_cost = subpath->startup_cost;
|
||||||
pathnode->path.total_cost += subpath->total_cost;
|
pathnode->path.total_cost += subpath->total_cost;
|
||||||
|
if (returningLists != NIL)
|
||||||
|
{
|
||||||
pathnode->path.rows += subpath->rows;
|
pathnode->path.rows += subpath->rows;
|
||||||
total_size += subpath->pathtarget->width * subpath->rows;
|
total_size += subpath->pathtarget->width * subpath->rows;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set width to the average width of the subpath outputs. XXX this is
|
* Set width to the average width of the subpath outputs. XXX this is
|
||||||
* totally wrong: we should report zero if no RETURNING, else an average
|
* totally wrong: we should return an average of the RETURNING tlist
|
||||||
* of the RETURNING tlist widths. But it's what happened historically,
|
* widths. But it's what happened historically, and improving it is a task
|
||||||
* and improving it is a task for another day.
|
* for another day.
|
||||||
*/
|
*/
|
||||||
if (pathnode->path.rows > 0)
|
if (pathnode->path.rows > 0)
|
||||||
total_size /= pathnode->path.rows;
|
total_size /= pathnode->path.rows;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user