From d2825e1c855e2ce0e9d3e6bc2c6f3d7793394a04 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 1 Sep 2007 18:47:39 +0000 Subject: [PATCH] Since sort_bounded_heap makes state changes that should be made regardless of the number of tuples involved, it's incorrect to skip it when memtupcount = 1; the number of cycles saved is minuscule anyway. An alternative solution would be to pull the state changes out to the call site in tuplesort_performsort, but keeping them near the corresponding changes in make_bounded_heap seems marginally cleaner. Noticed by Greg Stark. --- src/backend/utils/sort/tuplesort.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 18e4967d8c6..815dd2158d1 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -91,7 +91,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.77 2007/06/07 19:19:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.78 2007/09/01 18:47:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1068,8 +1068,7 @@ tuplesort_performsort(Tuplesortstate *state) * in memory, using a heap to eliminate excess tuples. Now we have * to transform the heap to a properly-sorted array. */ - if (state->memtupcount > 1) - sort_bounded_heap(state); + sort_bounded_heap(state); state->current = 0; state->eof_reached = false; state->markpos_offset = 0; -- 2.39.5