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

DISTINCT does not matter.