Due to the implementation of convert_ANY_sublink_to_join, we have limitations below, which has been discussed at [1] [2].
if (contain_vars_of_level((Node *) subselect, 1)) return NULL; I'm thinking if we can do the ${subject}. If so, the query like SELECT * FROM t1 WHERE a IN (SELECT * FROM t2 WHERE t2.b > t1.b); can be converted to SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE t2.b > t1.b AND t1.a = t2.a); Then the sublink can be removed with existing logic (the NOT-IN format will not be touched since they have different meanings). Any ideas? [1] https://www.postgresql.org/message-id/3691.1342650974%40sss.pgh.pa.us [2] https://www.postgresql.org/message-id/can_9jtx7n+cxeqlnu_uhxx+escsgxllungazt6sjvdpt7to...@mail.gmail.com -- Best Regards Andy Fan