1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Remove grotty use of disable_cost for TID scan plans.

Previously, the code charged disable_cost for CurrentOfExpr, and then
subtracted disable_cost from the cost of a TID path that used
CurrentOfExpr as the TID qual, effectively disabling all paths except
that one. Now, we instead suppress generation of the disabled paths
entirely, and generate only the one that the executor will actually
understand.

With this approach, we do not need to rely on disable_cost being
large enough to prevent the wrong path from being chosen, and we
save some CPU cycle by avoiding generating paths that we can't
actually use. In my opinion, the code is also easier to understand
like this.

Patch by me. Review by Heikki Linnakangas.

Discussion: http://postgr.es/m/591b3596-2ea0-4b8e-99c6-fad0ef2801f5@iki.fi
This commit is contained in:
Robert Haas
2024-07-22 14:57:53 -04:00
parent c0348fd0e3
commit e4326fbc60
4 changed files with 48 additions and 35 deletions

View File

@@ -772,6 +772,17 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
*/
required_outer = rel->lateral_relids;
/*
* Consider TID scans.
*
* If create_tidscan_paths returns true, then a TID scan path is forced.
* This happens when rel->baserestrictinfo contains CurrentOfExpr, because
* the executor can't handle any other type of path for such queries.
* Hence, we return without adding any other paths.
*/
if (create_tidscan_paths(root, rel))
return;
/* Consider sequential scan */
add_path(rel, create_seqscan_path(root, rel, required_outer, 0));
@@ -781,9 +792,6 @@ set_plain_rel_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
/* Consider index scans */
create_index_paths(root, rel);
/* Consider TID scans */
create_tidscan_paths(root, rel);
}
/*