Re: PoC: Partial sort - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: PoC: Partial sort
Date
Msg-id 52B24808.6090704@proxel.se
Whole thread Raw
In response to Re: PoC: Partial sort  (Alexander Korotkov <aekorotkov@gmail.com>)
List pgsql-hackers
On 12/18/2013 01:02 PM, Alexander Korotkov wrote:
>     My idea for a solution was to modify tuplesort to allow storing the
>     already sorted keys in either memtuples or the sort result file, but
>     setting a field so it does not sort thee already sorted tuples
>     again. This would allow the rescan to work as it used to, but I am
>     unsure how clean or ugly this code would be. Was this something you
>     considered?
>
>
> I'm not sure. I believe that best answer depends on particular
> parameter: how much memory we've for sort, how expensive is underlying
> node and how it performs rescan, how big are groups in partial sort.

Yes, if one does not need a rescan your solution will use less memory 
and about the same amount of CPU (if the tuplesort does not spill to 
disk). While if we keep all the already sorted tuples in the tuplesort 
rescans will be cheap but more memory will be used with an increased 
chance of spilling to disk.

-- 
Andreas Karlsson



pgsql-hackers by date:

Previous
From: Cédric Villemain
Date:
Subject: Re: pg_rewarm status
Next
From: Alvaro Herrera
Date:
Subject: Re: pg_rewarm status