postgresql/src
David Rowley 1083f94dac Be smarter about freeing tuples during tuplesorts
During dumptuples() the call to writetuple() would pfree any non-null
tuple.  This was quite wasteful as this happens just before we perform a
reset of the context which stores all of those tuples.

It seems to make sense to do a bit of a code refactor to make this work,
so here we just get rid of the writetuple function and adjust the WRITETUP
macro to call the state's writetup function.  The WRITETUP usage in
mergeonerun() always has state->slabAllocatorUsed == true, so writetuple()
would never free the tuple or do any memory accounting.  The only call
path that needs memory accounting done is in dumptuples(), so let's just
do it manually there.

In passing, let's get rid of the state->memtupcount-- code that counts the
memtupcount down to 0 one tuple at a time inside the loop.  That seems to
be a rather inefficient way to set memtupcount to 0, so let's just zero it
after the loop instead.

Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqZXoDCyrfCzZJR0-xH+7_q+GgitcQiYXUjRani7h4j8Q@mail.gmail.com
2022-09-01 11:08:10 +12:00
..
backend Be smarter about freeing tuples during tuplesorts 2022-09-01 11:08:10 +12:00
bin Refactor check_ functions to use filehandle for status 2022-08-31 13:06:50 +02:00
common Clean up inconsistent use of fflush(). 2022-08-29 13:55:41 -04:00
fe_utils Clean up inconsistent use of fflush(). 2022-08-29 13:55:41 -04:00
include Derive freeze cutoff from nextXID, not OldestXmin. 2022-08-31 11:37:35 -07:00
interfaces Fix MSVC warning in compat_informix/rnull.pgc 2022-08-31 09:31:22 -07:00
makefiles
pl plpython: Don't create pgxsdir subdirectory in installdir target 2022-08-31 07:42:01 +02:00
port Cleanup more code and comments related to Windows NT4 (XP days) 2022-08-30 09:52:58 +09:00
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:28:37 -04:00
test Fix a bug in roles_is_member_of. 2022-08-31 08:22:24 -04:00
timezone
tools Improve performance of and reduce overheads of memory management 2022-08-29 17:15:00 +12:00
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Remove unused configure variable. 2022-08-18 11:22:13 -04:00
Makefile.shlib aix: Fix SHLIB_EXPORTS reference in VPATH builds 2022-08-24 20:39:46 -07:00
nls-global.mk