Re: Planner making bad choice in alternative subplan decision

2020-09-29 Thread David Rowley
On Wed, 30 Sep 2020 at 04:42, Tom Lane wrote: > > David Rowley writes: > > On Tue, 29 Sep 2020 at 12:08, Tom Lane wrote: > >> The idea I'd had was to adjust make_subplan and cost_subplan to estimate > >> EXIST cases on the basis of either 50% retrieval (same as ANY/ALL) or > >> maybe full retrie

Re: Planner making bad choice in alternative subplan decision

2020-09-29 Thread Tom Lane
David Rowley writes: > On Tue, 29 Sep 2020 at 12:08, Tom Lane wrote: >> The idea I'd had was to adjust make_subplan and cost_subplan to estimate >> EXIST cases on the basis of either 50% retrieval (same as ANY/ALL) or >> maybe full retrieval if you want to be pessimistic. I've not had time >> to

Re: Planner making bad choice in alternative subplan decision

2020-09-28 Thread David Rowley
On Tue, 29 Sep 2020 at 12:08, Tom Lane wrote: > > David Rowley writes: > > Any opinions on this? > > This patch scares the heck out of me. It's a pretty much unprincipled > change in a fundamental selectivity estimator, which is going to affect > all sorts of queries not only the particular case

Re: Planner making bad choice in alternative subplan decision

2020-09-28 Thread David Rowley
Thanks for chipping in here. On Tue, 29 Sep 2020 at 12:08, Tom Lane wrote: > > David Rowley writes: > > Any opinions on this? > > This patch scares the heck out of me. It's a pretty much unprincipled > change in a fundamental selectivity estimator, which is going to affect > all sorts of querie

Re: Planner making bad choice in alternative subplan decision

2020-09-28 Thread Tom Lane
David Rowley writes: > Any opinions on this? This patch scares the heck out of me. It's a pretty much unprincipled change in a fundamental selectivity estimator, which is going to affect all sorts of queries not only the particular case you have in mind. There's no reason to think that the outco

Re: Planner making bad choice in alternative subplan decision

2020-09-28 Thread David Rowley
On Mon, 28 Sep 2020 at 13:22, David Rowley wrote: > I'm more leaning towards the fact that the planner picked the seqscan > path in the first place. Unfotunately I don't have any great ideas on > how to fix without fudging the costs a bit. Maybe we can make > var_eq_non_const() divide down the sel

Planner making bad choice in alternative subplan decision

2020-09-27 Thread David Rowley
This follows on from what I mentioned in [1]. I'll reiterate below: Really the topic is much more broad than what I wrote above, but the example case I have is around subplan costing which results in the alternative subplan code making a bad choice. So the example case is: create table t (a int,