Re: BUG #17826: An assert failed in /src/backend/optimizer/util/var.c

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: xinwen@stu.scu.edu.cn, pgsql-bugs@lists.postgresql.org
Date: 2023-03-17T03:34:14Z
Lists: pgsql-bugs
David Rowley <dgrowleyml@gmail.com> writes:
> I kinda also wanted to do the attached so that the logic to push or
> not to push was more centralised.  I just couldn't figure out exactly
> why we don't push down pseudoconstant quals, therefore, was unable to
> document that sufficiently in the header comment in
> qual_is_pushdown_safe().

A pseudoconstant qual turns into a filtering Result node with a one-time
condition that controls whether it runs the child plan at all.  You want
to put those as high in the plan tree as possible, so that they cut off
the maximum possible amount of work when the one-time condition is false.
So pushing one down into a subplan would be downright counterproductive.

			regards, tom lane



Commits

  1. Fix incorrect logic for determining safe WindowAgg run conditions

  2. Teach planner and executor about monotonic window funcs