On Tue, Apr 12, 2022 at 7:58 AM David Rowley <dgrowle...@gmail.com> wrote: > > I've attached the patch I tested. It was thrown together very quickly > just to try out the performance. If it's interesting I can polish it > up a bit. If not, I didn't waste too much time.
@@ -959,6 +965,10 @@ tuplesort_begin_batch(Tuplesortstate *state) state->tapeset = NULL; + /* check if specialized sorts can skip calling the tiebreak function */ + state->oneKeySort = state->nKeys == 1 && + !state->sortKeys[0].abbrev_converter; + IIUC, this function is called by tuplesort_begin_common, which in turn is called by tuplesort_begin_{heap, indexes, etc}. The latter callers set the onlyKey and now oneKeySort variables as appropriate, and sometimes hard-coded to false. Is it intentional to set them here first? Falling under the polish that you were likely thinking of above: We might rename oneKeySort to skipTiebreaker to avoid confusion. SInce the test for these variable is the same, we could consolidate them into a block and reword this existing comment (which I find a little confusing anyway): /* * The "onlyKey" optimization cannot be used with abbreviated keys, since * tie-breaker comparisons may be required. Typically, the optimization * is only of value to pass-by-value types anyway, whereas abbreviated * keys are typically only of value to pass-by-reference types. */ I can take a stab at this, unless you had something else in mind. -- John Naylor EDB: http://www.enterprisedb.com