MDL-38596 Optimise SQL in preloading course contacts for number of courses