diff options
author | David Rowley <drowley@postgresql.org> | 2022-07-13 15:03:47 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2022-07-13 15:03:47 +1200 |
commit | c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4 (patch) | |
tree | b0e092c52196ba79555157a75b498b4ea9b8c4d9 /src/backend/optimizer/plan/createplan.c | |
parent | 50e4c280f0661f3ef837d2c3beb5fcc100202324 (diff) | |
download | postgresql-c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4.tar.gz postgresql-c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4.zip |
Use list_copy_head() instead of list_truncate(list_copy(...), ...)
Truncating off the end of a freshly copied List is not a very efficient
way of copying the first N elements of a List.
In many of the cases that are updated here, the pattern was only being
used to remove the final element of a List. That's about the best case
for it, but there were many instances where the truncate trimming the List
down much further.
4cc832f94 added list_copy_head(), so let's use it in cases where it's
useful.
Author: David Rowley
Discussion: https://postgr.es/m/1986787.1657666922%40sss.pgh.pa.us
Diffstat (limited to 'src/backend/optimizer/plan/createplan.c')
-rw-r--r-- | src/backend/optimizer/plan/createplan.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 76606faa3e4..e37f2933eb8 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -1397,8 +1397,7 @@ create_append_plan(PlannerInfo *root, AppendPath *best_path, int flags) */ if (tlist_was_changed && (flags & (CP_EXACT_TLIST | CP_SMALL_TLIST))) { - tlist = list_truncate(list_copy(plan->plan.targetlist), - orig_tlist_length); + tlist = list_copy_head(plan->plan.targetlist, orig_tlist_length); return inject_projection_plan((Plan *) plan, tlist, plan->plan.parallel_safe); } @@ -1557,7 +1556,7 @@ create_merge_append_plan(PlannerInfo *root, MergeAppendPath *best_path, */ if (tlist_was_changed && (flags & (CP_EXACT_TLIST | CP_SMALL_TLIST))) { - tlist = list_truncate(list_copy(plan->targetlist), orig_tlist_length); + tlist = list_copy_head(plan->targetlist, orig_tlist_length); return inject_projection_plan(plan, tlist, plan->parallel_safe); } else |