MDL-62384 mod_assign: Update to sql query for performance.