| From: | David Rowley <drowley(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Reduce memory overheads for storing a Memoize tuple |
| Date: | 2026-08-21 02:50:42 |
| Message-ID: | E1wxFL7-00000001Rru-0kfV@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <dgrowleyml(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAApHDvoNurQzpR2nZ4aLq1v_4gstsSdimZP-m34PMTBPptn+zQ@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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2026-08-21 03:37:38 | pgsql: psql: Do not let invalid \getresults affect the next query |
| Previous Message | Bruce Momjian | 2026-08-21 01:35:50 | pgsql: doc: fix wording in SELECT docs |