Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.
Date
Msg-id 8810.1590714246@sss.pgh.pa.us
Whole thread Raw
In response to Re: Make the qual cost on index Filter slightly higher than qualcost on index Cond.  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: Make the qual cost on index Filter slightly higher than qual coston index Cond.  (Andy Fan <zhihui.fan1213@gmail.com>)
List pgsql-hackers
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes:
> On Wed, May 27, 2020 at 09:58:04PM +0800, Andy Fan wrote:
>> so we need to optimize the cost model for such case, the method is the
>> patch I mentioned above.

> Making the planner more robust w.r.t. to estimation errors is nice, but
> I wouldn't go as far saying we should optimize for such cases.

Yeah, it's a serious mistake to try to "optimize" for cases where we have
no data or wrong data.  By definition, we don't know what we're doing,
so who's to say whether we've made it better or worse?  And the possible
side effects on cases where we do have good data are not to be ignored.

> Anyway, I kinda doubt making the conditions 1.001 more expensive is a
> way to make the planning more robust. I'm pretty sure we could construct
> examples in the opposite direction, in which case this change make it
> more likely we use the wrong index.

The other serious error we could be making here is to change things on
the basis of just a few examples.  You really need a pretty wide range
of test cases to be sure that you're not making things worse, any time
you're twiddling basic parameters like these.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: segmentation fault using currtid and partitioned tables
Next
From: Andres Freund
Date:
Subject: Re: segmentation fault using currtid and partitioned tables