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 generate_orderedappend_paths
Date: Mon, 20 Feb 2023 09:50:48 +0000
Message-ID: <E1pU2op-00246F-Um@gemulon.postgresql.org> (raw)

Optimize generate_orderedappend_paths

In generate_orderedappend_paths(), when match_partition_order_desc was
true, we would lcons() items to various lists in a loop over each live
partition.  When the number of live partitions was large, the lcons()
could show up in profiles due to it having to perform memmove() to make
way for the new list item.

Here we adjust things so that we just perform the loop over the live
partitions backwards when match_partition_order_desc is true.  This allows
us to simplify the logic in the loop.  Now, as far as the guts of the loop
knows, there's no difference between match_partition_order and
match_partition_order_desc.  We can just set match_partition_order to true
so that we build the correct list of paths for the asc and desc case. Per
idea from Andres Freund.

Discussion: https://postgr.es/m/20230217002351.nyt4y5tdzg6hugdt@awork3.anarazel.de

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/94cad7a3e6040e23d51b9d4869fc20e3e56ddbf7

Modified Files
--------------
src/backend/optimizer/path/allpaths.c | 57 +++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 23 deletions(-)



Message-ID: <E1pU2op-00246F-Um@gemulon.postgresql.org>
Permalink:  ../E1pU2op-00246F-Um@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pU2op-00246F-Um@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 generate_orderedappend_paths
  In-Reply-To: <E1pU2op-00246F-Um@gemulon.postgresql.org>
  References: <E1pU2op-00246F-Um@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