public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: =?utf-8?B?WHVhbiBDaGVu?= <[email protected]>
Cc: =?utf-8?B?cGdzcWwtcGVyZm9ybWFuY2U=?= <[email protected]>
Subject: Re: Question: Is it valid for a parent node's total cost to be lower than a child's total cost in EXPLAIN?
Date: Sat, 19 Jul 2025 21:57:50 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

"=?utf-8?B?WHVhbiBDaGVu?=" <[email protected]> writes:
> In some cases, I noticed that a parent path node's total cost is less than that of one of its child path nodes. I initially expected that the total cost of a node should be at least as large as the sum of its child nodes’ total costs, or at least not smaller than any single child.

That is true if we expect the parent node to run its child node(s) to
completion, but there are cases where we don't.  An obvious example
is a Limit node.  In the case at hand, the planner is betting that
the Merge will not need to run one side to completion because the
other side's largest join key value is less than the first side's
largest value.  The merge can stop as soon as either input is
exhausted.

			regards, tom lane





view thread (2+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: Question: Is it valid for a parent node's total cost to be lower than a child's total cost in EXPLAIN?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox