Re: Startup cost of sequential scan - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Startup cost of sequential scan
Date
Msg-id 8207.1535641118@sss.pgh.pa.us
Whole thread Raw
In response to Re: Startup cost of sequential scan  (Alexander Korotkov <a.korotkov@postgrespro.ru>)
Responses Re: Startup cost of sequential scan
Re: Startup cost of sequential scan
List pgsql-hackers
Alexander Korotkov <a.korotkov@postgrespro.ru> writes:
> On Thu, Aug 30, 2018 at 5:05 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Because it's what the mental model of startup cost says it should be.

> From this model we make a conclusion that we're starting getting rows
> from sequential scan sooner than from index scan.  And this conclusion
> doesn't reflect reality.

No, startup cost is not the "time to find the first row".  It's overhead
paid before you even get to start examining rows.

I'm disinclined to consider fundamental changes to our costing model
on the basis of this example.  The fact that the rowcount estimates are
so far off reality means that you're basically looking at "garbage in,
garbage out" for the cost calculations --- and applying a small LIMIT
just magnifies that.

It'd be more useful to think first about how to make the selectivity
estimates better; after that, we might or might not still think there's
a costing issue.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Erik Rijkers
Date:
Subject: Re: rare crash - FailedAssertion snapbuild.c Line: 580
Next
From: Konstantin Knizhnik
Date:
Subject: Re: Startup cost of sequential scan