Re: Sort performance cliff with small work_mem - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Sort performance cliff with small work_mem
Date
Msg-id CAH2-Wzk6n_puDM8K=NhALZ68+i3Ffej4GfpXNL0Aw7Y2gj28bA@mail.gmail.com
Whole thread Raw
In response to Re: Sort performance cliff with small work_mem  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
On Wed, May 2, 2018 at 10:43 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> I'm not sure what you could derive that from, to make it less arbitrary. At
> the moment, I'm thinking of just doing something like this:
>
> /*
>  * Minimum amount of memory reserved to hold the sorted tuples in
>  * TSS_BUILDRUNS phase.  This specifies a minimum size for the merge runs,
>  * when work_mem is very small.
>  */
> #define MIN_TUPLE_MEMORY        (32 * 1024)

If you end up doing something like this, I suggest that you also
change this code to simply assign 1024 (or maybe a new preprocessor
constant):

state->memtupsize = Max(1024, ALLOCSET_SEPARATE_THRESHOLD /
sizeof(SortTuple) + 1);

The ALLOCSET_SEPARATE_THRESHOLD part can become a static assertion.

-- 
Peter Geoghegan


pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Sort performance cliff with small work_mem
Next
From: Tom Lane
Date:
Subject: Re: Sort performance cliff with small work_mem