Avoid n+1 query issue when eager_loading is used