From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: James Coleman <jtc331@gmail.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Rafia Sabih <rafia.pghackers@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: Simon Riggs <simon@2ndquadrant.com>
Cc: Shaun Thomas <shaun.thomas@2ndquadrant.com>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Cc: Andreas Karlsson <andreas@proxel.se>
Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort)
Date: Tue, 31 Mar 2020 13:31:26 -0300
Message-ID: <20200331163126.GA6532@alvherre.pgsql> (raw)
In-Reply-To: <CAAaqYe8hK3FpBRkAtTn1L_sETMUivoR=knoLf5by6Q7yLZnzTg@mail.gmail.com>
On 2020-Mar-30, James Coleman wrote:
> +/* ----------------
> + * Instruementation information for IncrementalSort
> + * ----------------
> + */
> +typedef struct IncrementalSortGroupInfo
> +{
> + int64 groupCount;
> + long maxDiskSpaceUsed;
> + long totalDiskSpaceUsed;
> + long maxMemorySpaceUsed;
> + long totalMemorySpaceUsed;
> + Size sortMethods; /* bitmask of TuplesortMethod */
> +} IncrementalSortGroupInfo;
There's a typo "Instruementation" in the comment, but I'm more surprised
that type Size is being used to store a bitmask. It looks weird to me.
Wouldn't it be more reasonable to use bits32 or some such? (I first
noticed this in the "sizeof(Size)" code that appears in the explain
code.)
OTOH, aesthetically it would seem to be better to define these values
using ones and increasing shifts (1 << 1 and so on), rather than powers
of two:
> + * TuplesortMethod is used in a bitmask in Increment Sort's shared memory
> + * instrumentation so needs to have each value be a separate bit.
> */
> typedef enum
> {
> SORT_TYPE_STILL_IN_PROGRESS = 0,
> - SORT_TYPE_TOP_N_HEAPSORT,
> - SORT_TYPE_QUICKSORT,
> - SORT_TYPE_EXTERNAL_SORT,
> - SORT_TYPE_EXTERNAL_MERGE
> + SORT_TYPE_TOP_N_HEAPSORT = 2,
> + SORT_TYPE_QUICKSORT = 4,
> + SORT_TYPE_EXTERNAL_SORT = 8,
> + SORT_TYPE_EXTERNAL_MERGE = 16
> } TuplesortMethod;
I don't quite understand why you skipped "1". (Also, is the use of zero
a wise choice?)
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, jtc331@gmail.com, tomas.vondra@2ndquadrant.com, michael@paquier.xyz, rafia.pghackers@gmail.com, pg@bowt.ie, simon@2ndquadrant.com, shaun.thomas@2ndquadrant.com, 9erthalion6@gmail.com, a.korotkov@postgrespro.ru, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org, andreas@proxel.se
Subject: Re: [PATCH] Incremental sort (was: PoC: Partial sort)
In-Reply-To: <20200331163126.GA6532@alvherre.pgsql>
* 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