CRM-13614: query optimization on dynamic groups using only one left join