Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-29 Thread Andy Fan
> 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. >> >> > I will try more

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-29 Thread Andy Fan
On Fri, May 29, 2020 at 9:37 PM Ashutosh Bapat wrote: > On Fri, May 29, 2020 at 6:40 AM 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

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-29 Thread Ashutosh Bapat
On Fri, May 29, 2020 at 6:40 AM 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

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-28 Thread Andy Fan
Thanks all of you for your feedback. On Fri, May 29, 2020 at 9:04 AM Tom Lane wrote: > Tomas Vondra 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

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-28 Thread Andy Fan
> >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. The stats > can be arbitrarily off, so should we expect

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-28 Thread Tom Lane
Tomas Vondra 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

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-28 Thread Tomas Vondra
On Wed, May 27, 2020 at 09:58:04PM +0800, Andy Fan wrote: On Wed, May 27, 2020 at 8:01 PM Ashutosh Bapat < ashutosh.ba...@2ndquadrant.com> wrote: On Wed, 27 May 2020 at 04:43, Andy Fan wrote: You can use the attached sql to reproduce this issue, but I'm not sure you can get the above

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-27 Thread Andy Fan
On Wed, May 27, 2020 at 8:01 PM Ashutosh Bapat < ashutosh.ba...@2ndquadrant.com> wrote: > > > On Wed, 27 May 2020 at 04:43, Andy Fan wrote: > >> You can use the attached sql to reproduce this issue, but I'm not sure >> you can >> get the above result at the first time that is because when

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-27 Thread Ashutosh Bapat
On Wed, 27 May 2020 at 04:43, Andy Fan wrote: > You can use the attached sql to reproduce this issue, but I'm not sure you > can > get the above result at the first time that is because when optimizer > think the > 2 index scan have the same cost, it will choose the first one it found, > the

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-26 Thread Andy Fan
You can use the attached sql to reproduce this issue, but I'm not sure you can get the above result at the first time that is because when optimizer think the 2 index scan have the same cost, it will choose the first one it found, the order depends on RelationGetIndexList. If so, you may try

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-26 Thread Andy Fan
On Tue, May 26, 2020 at 9:59 PM Ashutosh Bapat wrote: > On Tue, May 26, 2020 at 1:52 PM Andy Fan wrote: > > > > > > Consider the below example: > > > > create table j1(i int, im5 int, im100 int, im1000 int); > > insert into j1 select i, i%5, i%100, i%1000 from generate_series(1, > 1000)i;

Re: Make the qual cost on index Filter slightly higher than qual cost on index Cond.

2020-05-26 Thread Ashutosh Bapat
On Tue, May 26, 2020 at 1:52 PM Andy Fan wrote: > > > Consider the below example: > > create table j1(i int, im5 int, im100 int, im1000 int); > insert into j1 select i, i%5, i%100, i%1000 from generate_series(1, > 1000)i; > create index j1_i_im5 on j1(i, im5); > create index j1_i_im100 on