On Fri, Jun 5, 2020 at 9:08 AM Alexey Bashtanov <bashta...@imap.cc> wrote:
> > In [1] we found a situation where it leads to a suboptimal plan, > as it bloats the overall cost into large figures, > a decision related to an outer part of the plan look negligible to the > planner, > and as a result it doesn't elaborate on choosing the optimal one. > > I've just started looking at this patch today, but I was wondering if you might include a test case which minimally reproduces the original problem you had. The only plan diff I see is in updatable_views.sql, and it doesn't illustrate the problem as well as a more straightforward SELECT query with EXISTS sublink might. After putting in some logging, I see that there are only a few non-catalog queries which exercise this code path. This query from groupingsets.sql is an example of one such query: select ten, sum(distinct four) from onek a group by grouping sets((ten,four),(ten)) having exists (select 1 from onek b where sum(distinct a.four) = b.four); But, the chosen plan for this query stays the same. It would be helpful to see a query where a different plan is chosen because of this change that is not from updatable_views.sql. -- Melanie Plageman