Thread
-
Re: Support loser tree for k-way merge
cca5507 <cca5507@qq.com> — 2025-12-04T03:49:07Z
Hi, Thank you for your reply. > Can we drive the decision for what to do based on optimizer > stats, i.e. n_distinct and row counts? Not sure what the calculation would > be specifically, but something else to consider. > > We can still provide the GUC to override the optimizer decisions, > but at least the optimizer, given up-to-date stats, may get it right most > of the time. That makes sense to me. TODO ==== 1) Consider optimizer statistics when deciding whether to use the heap or the loser tree. 2) Do we need a USEMEM() call to the array of losers? 3) Now the array length of losers is MAXORDER * 2, and in fact MAXORDER is enough, need some refactor of the code. (Is it worth doing?) 4) Add more code comments and doc. Help are welcome! -- Regards, ChangAo Chen