Since sort_bounded_heap makes state changes that should be made
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 Sep 2007 18:47:39 +0000 (18:47 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 Sep 2007 18:47:39 +0000 (18:47 +0000)
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

index 97cd532b711ddfadb63d0367481fa4fe42669896..f1472b83298f2c1d03853d0b5196cdc9a033a92e 100644 (file)
@@ -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;