Thread

  1. Re: Support loser tree for k-way merge

    cca5507 <cca5507@qq.com> — 2025-12-03T12:59:13Z

    Hi Heikki,
    
    > What is the worst case scenario for the loser tree, where the heap is 
    > faster? How big is the difference?
    
    In tuplesort_heap_replace_top(), it has 2 comparisons each level, but it can early return
    if the parent less than both child.
    
    In tuplesort_loser_tree_adjust(), it has 1 comparison each level, but it can't early return.
    
    So on specific data, the heap may be better than the loser tree. But I think the possibility
    is very small.
    
    --
    Regards,
    ChangAo Chen