Hi,
EXPLAIN command doesn't show testexpr. Sometimes it is not easy to
understand a query plan. That I mean:
CREATE TABLE a (x integer, y integer);
EXPLAIN (COSTS OFF, VERBOSE) SELECT x, y FROM a upper
WHERE y IN (SELECT y FROM a WHERE upper.y = x);
EXPLAIN (COSTS OFF, VERBOSE) SELECT x, y FROM a upper
WHERE x+y IN (SELECT y FROM a WHERE upper.y = x);
These two explains have the same representation:
Seq Scan on public.a upper
Output: upper.x, upper.y
Filter: (SubPlan 1)
SubPlan 1
-> Seq Scan on public.a
Output: a.y
Filter: (upper.y = a.x)
It is a bit annoying when you don't have original query or don't trust
competence of a user who sent you this explain.
In attachment - patch which solves this problem. I'm not completely sure
that this option really needed and patch presents a proof of concept only.
--
regards,
Andrey Lepikhov
Postgres Professional