Re: 7k records into Sort node, 4.5m out? - Mailing list pgsql-performance

From Tom Lane
Subject Re: 7k records into Sort node, 4.5m out?
Date
Msg-id 1059.1345477224@sss.pgh.pa.us
Whole thread Raw
In response to Re: 7k records into Sort node, 4.5m out?  (Josh Berkus <josh@agliodbs.com>)
Responses Re: 7k records into Sort node, 4.5m out?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-performance
Josh Berkus <josh@agliodbs.com> writes:
> I guess what I'm really not understanding is why it's calculating a cost
> of 3.7m for the index scan, and then discarding that *entire* cost and
> not including it in the total cost of the query?

It isn't ... or at least, you've offered no evidence that it is.
It's discounting some fraction of the cost on the (apparently correct)
basis that the merge won't read that input all the way to the end.
Whether it's discounted by an appropriate fraction is hard to tell
from the information given.  The actual rows count is about a quarter
the whole-scan estimate, so a multiplier of 0.25 seems right in
hindsight, and that seems to match up roughly right with the mergejoin
cost estimate --- but not knowing the actual table size, there's a lot
of uncertainty here.

            regards, tom lane


pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Re: 7k records into Sort node, 4.5m out?
Next
From: Josh Berkus
Date:
Subject: Re: 7k records into Sort node, 4.5m out?