I think the reason the planner isn't too bright about this case is
http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=cd1f0d04bf06938c0ee5728fc8424d62bcf2eef3
ie, it won't do IN/EXISTS pullup below a NOT EXISTS.
HEAD is better, thanks to commit
0816fad6eebddb8f1f0e21635e46625815d690b9, but of course there is no
chance at all of back-patching the planner changes that depends on.
I found that it works fine for [NOT] EXISTS if I just fold query inside
into "select 1 from (...) vv". With my provided query, it uses seqscan
for both EXISTS/NOT EXISTS without folding, and index scan with it.
Okay, it's easier for me to make automatic subquery folding.
Regards,
Dmitry
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers