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: Optimize a few list_delete_ptr calls
Date: Thu, 22 Oct 2020 01:37:07 +0000
Message-ID: <E1kVPXP-0005e4-3E@gemulon.postgresql.org> (raw)

Optimize a few list_delete_ptr calls

There is a handful of places where we called list_delete_ptr() to remove
some element from a List.  In many of these places we know, or with very
little additional effort know the index of the ListCell that we need to
remove.

Here we change all of those places to instead either use one of;
list_delete_nth_cell(), foreach_delete_current() or list_delete_last().
Each of these saves from having to iterate over the list to search for the
element to remove by its pointer value.

There are some small performance gains to be had by doing this, but in the
general case, none of these lists are likely to be very large, so the
lookup was probably never that expensive anyway.  However, some of the
calls are in fairly hot code paths, e.g process_equivalence().  So any
small gains there are useful.

Author: Zhijie Hou and David Rowley
Discussion: https://postgr.es/m/b3517353ec7c4f87aa560678fbb1034b@G08CNEXMBPEKD05.g08.fujitsu.local

Branch
------
master

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

Modified Files
--------------
src/backend/optimizer/path/equivclass.c | 9 +++++++--
src/backend/optimizer/path/joinpath.c   | 4 ++--
src/backend/parser/parse_expr.c         | 5 +++--
src/backend/parser/parse_utilcmd.c      | 4 +++-
src/backend/rewrite/rewriteHandler.c    | 6 +-----
5 files changed, 16 insertions(+), 12 deletions(-)



Message-ID: <E1kVPXP-0005e4-3E@gemulon.postgresql.org>
Permalink:  ../E1kVPXP-0005e4-3E@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kVPXP-0005e4-3E@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: Optimize a few list_delete_ptr calls
  In-Reply-To: <E1kVPXP-0005e4-3E@gemulon.postgresql.org>
  References: <E1kVPXP-0005e4-3E@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