MDL-46044 Assign: Add conditions to the inner query for performance