Fixing n+1 query problem on weights queries