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

Spell "distinct" correctly -- not in two other ways.