pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix tuplesort memory accounting for datum sorts on byref types 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix tuplesort memory accounting for datum sorts on byref types @ 2026-10-05 12:21 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: David Rowley @ 2026-10-05 12:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix tuplesort memory accounting for datum sorts on byref types 6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for non-bounded sorts in order to save memory and increase performance. That commit didn't get the memory accounting correct for datum sorts and mistakenly passed 0 bytes to tuplesort_puttuple_common(). That was correct for byval types, but failed to take into account palloc'd memory for byref types. Fix by using datumGetSize() when using the bump allocator and by using GetMemoryChunkSpace() when not. Backpatch to v17, where 6ed83d5fa was added. Author: Mario Karuza <mkaruza.pg@icloud.com> Reviewed-by: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Joao Detomini <joao.detomini@enterprisedb.com> Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com Backpatch-through: 17 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/85adc584e2bd3ee6ce1899929fc60afb709b4772 Modified Files -------------- src/backend/utils/sort/tuplesortvariants.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix tuplesort memory accounting for datum sorts on byref types @ 2026-10-05 12:21 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: David Rowley @ 2026-10-05 12:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix tuplesort memory accounting for datum sorts on byref types 6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for non-bounded sorts in order to save memory and increase performance. That commit didn't get the memory accounting correct for datum sorts and mistakenly passed 0 bytes to tuplesort_puttuple_common(). That was correct for byval types, but failed to take into account palloc'd memory for byref types. Fix by using datumGetSize() when using the bump allocator and by using GetMemoryChunkSpace() when not. Backpatch to v17, where 6ed83d5fa was added. Author: Mario Karuza <mkaruza.pg@icloud.com> Reviewed-by: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Joao Detomini <joao.detomini@enterprisedb.com> Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com Backpatch-through: 17 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/a2148471b0db8fb44c43d5a2933d99c82f3aa0c8 Modified Files -------------- src/backend/utils/sort/tuplesortvariants.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix tuplesort memory accounting for datum sorts on byref types @ 2026-10-05 12:22 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: David Rowley @ 2026-10-05 12:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix tuplesort memory accounting for datum sorts on byref types 6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for non-bounded sorts in order to save memory and increase performance. That commit didn't get the memory accounting correct for datum sorts and mistakenly passed 0 bytes to tuplesort_puttuple_common(). That was correct for byval types, but failed to take into account palloc'd memory for byref types. Fix by using datumGetSize() when using the bump allocator and by using GetMemoryChunkSpace() when not. Backpatch to v17, where 6ed83d5fa was added. Author: Mario Karuza <mkaruza.pg@icloud.com> Reviewed-by: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Joao Detomini <joao.detomini@enterprisedb.com> Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com Backpatch-through: 17 Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8d5b228ae985e0c30df1cac95ec33e14599ef010 Modified Files -------------- src/backend/utils/sort/tuplesortvariants.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix tuplesort memory accounting for datum sorts on byref types @ 2026-10-05 12:22 David Rowley <drowley@postgresql.org> 0 siblings, 0 replies; 4+ messages in thread From: David Rowley @ 2026-10-05 12:22 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix tuplesort memory accounting for datum sorts on byref types 6ed83d5fa made it so tuplesorts could use a bump.c memory allocator for non-bounded sorts in order to save memory and increase performance. That commit didn't get the memory accounting correct for datum sorts and mistakenly passed 0 bytes to tuplesort_puttuple_common(). That was correct for byval types, but failed to take into account palloc'd memory for byref types. Fix by using datumGetSize() when using the bump allocator and by using GetMemoryChunkSpace() when not. Backpatch to v17, where 6ed83d5fa was added. Author: Mario Karuza <mkaruza.pg@icloud.com> Reviewed-by: David Rowley <dgrowleyml@gmail.com> Reviewed-by: Joao Detomini <joao.detomini@enterprisedb.com> Discussion: https://postgr.es/m/e9f9f54337cd86a982837763958518cdbf08863c.camel%40icloud.com Backpatch-through: 17 Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/2414028ab64bcffccfee75790a15b5960de8d095 Modified Files -------------- src/backend/utils/sort/tuplesortvariants.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-10-05 12:22 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-10-05 12:21 pgsql: Fix tuplesort memory accounting for datum sorts on byref types David Rowley <drowley@postgresql.org> 2026-10-05 12:21 pgsql: Fix tuplesort memory accounting for datum sorts on byref types David Rowley <drowley@postgresql.org> 2026-10-05 12:22 pgsql: Fix tuplesort memory accounting for datum sorts on byref types David Rowley <drowley@postgresql.org> 2026-10-05 12:22 pgsql: Fix tuplesort memory accounting for datum sorts on byref types David Rowley <drowley@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox