From: Tom Lane <tgl@sss.pgh.pa.us>
To: ChenhuiMo <chenhuimo.mch@qq.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [RFC PATCH] Cost-based delayed projection for ORDER BY ... LIMIT
Date: Fri, 04 Sep 2026 00:10:03 -0400
Message-ID: <1516159.1788495003@sss.pgh.pa.us> (raw)
In-Reply-To: <tencent_077318C5D9B6ADE9E99A42255C6ACC77DB06@qq.com>
References: <tencent_077318C5D9B6ADE9E99A42255C6ACC77DB06@qq.com>
"=?utf-8?B?Q2hlbmh1aU1v?=" <chenhuimo.mch@qq.com> writes:
> The attached POC therefore also postpones individually cheap expressions when:
> total_expression_cost * (input_rows - limit_tuples)
> >
> 10 * cpu_operator_cost * limit_tuples
> This roughly compares the expression work avoided on discarded rows with a conservative threshold proportional to the rows that survive the Sort.
So ... the problem with proposals like this is that our cost estimates
for scalar expressions are pretty nearly useless, rendering planning
decisions that are strongly dependent on them mostly junk. See for
example the sad fate of commit db0d67db2, eventually reverted at
f4c7c410e. (Read the commit message for f4c7c410e and the linked
email discussion.) I'm not so worried about cost estimates where
expression costs are only part of the total, but this proposal seems
completely dependent on expression costs, so I think it's likely to
be mostly garbage-in-garbage-out. What can we do to have more
confidence in the choice?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, chenhuimo.mch@qq.com
Subject: Re: [RFC PATCH] Cost-based delayed projection for ORDER BY ... LIMIT
In-Reply-To: <1516159.1788495003@sss.pgh.pa.us>
References: <tencent_077318C5D9B6ADE9E99A42255C6ACC77DB06@qq.com> <1516159.1788495003@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox