Re: Support loser tree for k-way merge

From: cca5507 <cca5507(at)qq(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support loser tree for k-way merge
Date: 2025-12-03 12:59:13
Message-ID: tencent_DCD98184361486D41AA430C8B0E0691D740A@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message cca5507 2025-12-03 13:18:57 Re: Support loser tree for k-way merge
Previous Message Ignat Remizov 2025-12-03 12:37:26 Re: [PATCH] Add enable_copy_program GUC to control COPY PROGRAM