Re: Fix gin index cost estimation - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: Fix gin index cost estimation
Date
Msg-id CAPpHfdt45WZPcS-R1BYLgixv+vW_+dTom6GHa-XZPu4mtfXTRg@mail.gmail.com
Whole thread Raw
In response to Re: Fix gin index cost estimation  (Ronan Dunklau <ronan.dunklau@aiven.io>)
Responses Re: Fix gin index cost estimation
List pgsql-hackers
Hi, Ronan!

On Wed, Oct 12, 2022 at 10:15 AM Ronan Dunklau <ronan.dunklau@aiven.io> wrote:
> > > You're right, I was too eager to try to raise the CPU cost proportionnally
> to
> > > the number of array scans (scalararrayop). I'd really like to understand
> where
> > > this equation comes from though...
> >
> > So, what's the latest update here?
>
> Thanks Michael for reviving this thread.
>
> Before proceeding any further with this, I'd like to understand where we
> stand. Tom argued my way of charging cost per entry pages visited boils down
> to charging per tuple, which I expressed disagreement with.
>
> If we can come to a consensus whether that's a bogus way of thinking about it
> I'll proceed with what we agree on.

I briefly read the thread. I think this line is copy-paste from other index access methods and trying to estimate the whole index scan CPU cost by bypassing all the details.

*indexTotalCost += (numTuples * *indexSelectivity) * (cpu_index_tuple_cost + qual_op_cost);

I think Tom's point was that it's wrong to add a separate entry-tree CPU cost estimation to another estimation, which tries (very inadequately) to estimate the whole scan cost. Instead, I propose writing better estimations for both entry-tree CPU cost and data-trees CPU cost and replacing existing CPU estimation altogether.

------
Regards,
Alexander Korotkov

pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: explain_regress, explain(MACHINE), and default to explain(BUFFERS) (was: BUFFERS enabled by default in EXPLAIN (ANALYZE))
Next
From: "Finnerty, Jim"
Date:
Subject: Re: parse partition strategy string in gram.y