Reduce memory overheads for storing a Memoize tuple

This uses 16 fewer bytes per tuple stored in each MemoizeEntry.  24 bytes
can be saved by not doing palloc_object(MemoizeTuple), and instead we
can store the pointer to the next tuple by requesting that
ExecCopySlotMinimalTupleExtra() allocate an extra 8 bytes per
MinimalTuple, a net saving of 16 bytes per cached tuple, which equates
to 33% less memory in the most extreme case (assuming very few entries
with many tuples and the narrowest possible MinimalTuple).  Real-world
cases will save less, as we're not saving anything on the MemoizeEntry
itself, only tuples stored within it.

Saving memory in Memoize allows more entries to exist concurrently and
reduces the chances that an entry will be evicted from the cache due to
memory pressure.  That increases the chances of getting cache hits.

Author: David Rowley <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Discussion: 
https://postgr.es/m/caaphdvonurqzpr2nz4alq1v_4gstssdimzp-m34pmtbpptn...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/609f969f61bbe0cab817a12c4b9f2c1c0fa3297f

Modified Files
--------------
src/backend/executor/nodeMemoize.c | 106 +++++++++++++++++++++++++------------
src/include/nodes/execnodes.h      |   8 ++-
src/tools/pgindent/typedefs.list   |   1 -
3 files changed, 75 insertions(+), 40 deletions(-)

Reply via email to