Stamatis>Out of curiosity does anybody know if popular DBMS (Postgres) support "hoisting"?
PostgreSQL does support it, and here's a reproducible case when that feature makes the query 300 times slower: https://gist.github.com/vlsi/df08cbef370b2e86a5c1 Vladimir