Query plan can't recongnize join when sql has 'WHERE'