Re: Using quicksort and a merge step to significantly improve on tuplesort's single run "external sort"

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Jeremy Harris <jgh(at)wizmail(dot)org>
Subject: Re: Using quicksort and a merge step to significantly improve on tuplesort's single run "external sort"
Date: 2015-07-30 23:18:15
Message-ID: CAM3SWZT4zVfo864x9oaJudquotGYMccr3F3VBNmSyYQY11oRqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jul 30, 2015 at 4:26 AM, Greg Stark <stark(at)mit(dot)edu> wrote:
> I'm a bit confused where the big win comes from though. Is what's going on
> that the external sort only exceeded memory by a small amount so nearly all
> the tuples are still in memory?

Yes, that's why this can be much faster just as the work_mem threshold
is crossed. You get an "almost internal" sort, which means you can
mostly quicksort, and you can avoid dumping most tuples. It's still a
pretty nice win when less than half of tuples fit in memory, though --
just not as nice. Below that, the optimization isn't used.

--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-07-30 23:26:47 Re: Using quicksort and a merge step to significantly improve on tuplesort's single run "external sort"
Previous Message Peter Geoghegan 2015-07-30 23:04:13 Re: Using quicksort and a merge step to significantly improve on tuplesort's single run "external sort"