pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use list_copy_head() instead of list_truncate(list_copy(...), ..
Date: Wed, 13 Jul 2022 03:04:38 +0000
Message-ID: <E1oBSg0-002Wx0-Pq@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c23e3e6beb273ae8c0f8e616edb7ed1acb0271c4

Modified Files
--------------
src/backend/catalog/objectaddress.c     |  8 ++++----
src/backend/commands/dropcmds.c         | 15 +++++++--------
src/backend/commands/sequence.c         |  2 +-
src/backend/optimizer/path/allpaths.c   |  9 ++++-----
src/backend/optimizer/path/indxpath.c   | 14 ++++++--------
src/backend/optimizer/path/pathkeys.c   |  2 +-
src/backend/optimizer/plan/createplan.c |  5 ++---
7 files changed, 25 insertions(+), 30 deletions(-)



Message-ID: <E1oBSg0-002Wx0-Pq@gemulon.postgresql.org>
Permalink:  ../E1oBSg0-002Wx0-Pq@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oBSg0-002Wx0-Pq@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org
  Subject: Re: pgsql: Use list_copy_head() instead of list_truncate(list_copy(...), ..
  In-Reply-To: <E1oBSg0-002Wx0-Pq@gemulon.postgresql.org>
  References: <E1oBSg0-002Wx0-Pq@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox