Add guards for unsupported subqueries join plan, optimize the possible subqueriese

All these parens around simple function calls and comparisons makes this statement harder to read.