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: Make better use of the new List implementation in a couple of pl
Date: Mon, 22 Jul 2019 07:03:37 +0000
Message-ID: <E1hpSMD-00022E-LC@gemulon.postgresql.org> (raw)

Make better use of the new List implementation in a couple of places

In nodeAppend.c and nodeMergeAppend.c there were some foreach loops which
looped over the list of subplans and only performed any work if the
subplan index was found in a Bitmapset.  With the old linked list
implementation of List, this form made sense as accessing the Nth list
element was O(N).  However, thanks to 1cff1b95a we now have array-based
lists, so accessing the Nth element has become O(1).

Here we make the most of the O(1) lookups and just loop over the set
members of the Bitmapset with bms_next_member().  This performs slightly
better when a small number of the list items are in the Bitmapset.  Micro
benchmarks show that when the Bitmapset contains all or most of the list
items then the new code is ever so slightly slower.  In practice, the cost
is so small that it's drowned out by various other things such as locking
the relations belonging to each subplan, etc.

The primary goal here is to leave better code examples around which benefit
better from the new list implementation.

Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CAKJS1f8ZcsLVgkF4wOfRyMYTcPgLFiUAOedFC+U2vK_aFZk-BA@mail.gmail.com

Branch
------
master

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

Modified Files
--------------
src/backend/executor/nodeAppend.c      | 25 ++++++++++---------------
src/backend/executor/nodeMergeAppend.c | 14 +++++---------
2 files changed, 15 insertions(+), 24 deletions(-)



Message-ID: <E1hpSMD-00022E-LC@gemulon.postgresql.org>
Permalink:  ../E1hpSMD-00022E-LC@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hpSMD-00022E-LC@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: Make better use of the new List implementation in a couple of pl
  In-Reply-To: <E1hpSMD-00022E-LC@gemulon.postgresql.org>
  References: <E1hpSMD-00022E-LC@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