Re: [Patch] Build the heap more efficient in tuplesort.c
cca5507 <cca5507@qq.com>
From: cca5507 <cca5507@qq.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-01T16:05:30Z
Lists: pgsql-hackers
Attachments
- v2-0001-Build-the-heap-more-efficient-in-tuplesort.c.patch (application/octet-stream)
Hi, Generally speaking, build the heap by tuplesort_heap_build() is O(n) while tuplesort_heap_insert() is O(n log n), so the former is better. I'm not sure why tuplesort_heap_build() is worse than tuplesort_heap_insert() when handling random data sometimes, maybe my test method is wrong? Any ideas? The v2-0001 refactor some code, mark some function as always inline and reduce some useless copy of SortTuple. -- Regards, ChangAo Chen