Re: Support loser tree for k-way merge

From: cca5507 <cca5507(at)qq(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: 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-04 03:49:07
Message-ID: tencent_6B00C6CE2E74AF50A01635C54AC600CFE705@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-12-04 03:56:31 Re: PATCH: jsonpath string methods: lower, upper, initcap, l/r/btrim, replace, split_part
Previous Message shveta malik 2025-12-04 03:27:48 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart