On Thu, Jul 30, 2015 at 4:26 AM, Greg Stark <st...@mit.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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers