In order to optimize the query performance, we should use target project id and target branch intead of cross-joining merge_requests table. Fix schema Fix schema