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-Wzkko2TmSfOrcxWjeT9pXS1yrdopaeeWaD43in4Xpv9cuw@mail.gmail.com
Whole thread Raw
In response to Sort performance cliff with small work_mem  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
On Wed, May 2, 2018 at 8:38 AM, Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> With a small work_mem values, maxTapes is always 6, so tapeSpace is 48 kB.
> With a small enough work_mem, 84 kB or below in this test case, there is not
> enough memory left at this point, so we don't subtract tapeSpace. However,
> with a suitably evil test case, you can get arbitrary close to the edge, so
> that we will subtract away almost all the remaining memory above, leaving
> only a few bytes for the tuples. In this example case, with work_mem='85
> kB', each quicksorted run consists of only 15 tuples on average.

This is an extreme example of the memtuples array and memory for
tuples becoming unbalanced. You'll have 1024 memtuples (24KiB), which
is rather a lot more than the 15 tuples that you can fit in this
example case.

I don't feel strongly about it, but arguably the minimum additional
amount of memory should be big enough that you have some chance of
using all 1024 SortTuples (the whole memtuples array).

-- 
Peter Geoghegan


pgsql-hackers by date:

Previous
From: ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Date:
Subject: Re: Transform for pl/perl
Next
From: "Joshua D. Drake"
Date:
Subject: GSOC 2018