Simon Riggs <simon@2ndquadrant.com> writes:
> The enclosed patch substantially improves large sort performance,
Applied with revisions. I thought the addition of the Tapestate structs
complicated the notation considerably without really buying anything,
so instead I just made the fixed-size arrays into pointers. A more
serious objection was that MaxTapes and TapeRange can't be globals,
they have to be struct fields, unless you want to assume that all sorts
in progress at a given time must use identical memory settings.
I also fixed some off-by-one logic in determining the appropriate number
of tapes, and added accounting for tape buffer space. It was somewhat
reasonable to ignore the LogicalTapeSet space when the number of tapes
was fixed and small, but in the new regime I think it's necessary to
account for the tape buffers while computing memory use.
regards, tom lane