Use list_copy_head() instead of list_truncate(list_copy(...), ...)
authorDavid Rowley <drowley@postgresql.org>
Wed, 13 Jul 2022 03:03:47 +0000 (15:03 +1200)
committerDavid Rowley <drowley@postgresql.org>
Wed, 13 Jul 2022 03:03:47 +0000 (15:03 +1200)
commitc23e3e6beb273ae8c0f8e616edb7ed1acb0271c4
treeb0e092c52196ba79555157a75b498b4ea9b8c4d9
parent50e4c280f0661f3ef837d2c3beb5fcc100202324
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
src/backend/catalog/objectaddress.c
src/backend/commands/dropcmds.c
src/backend/commands/sequence.c
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/pathkeys.c
src/backend/optimizer/plan/createplan.c