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