Filter Merge Requests by target branch
What does this MR do?
Filter Merge Requests by target branch.
Target branches for autocomplete are loaded top 100 target branches ordering them by last updated. And those branches are filtered on frontend, not backend. So older target branches are not shown in the list, but I think merge target branches is less than 100 in many projects.
Are there points in the code the reviewer needs to double check?
Filter merge requests by target branch
Query
SELECT "merge_requests".*
FROM "merge_requests"
WHERE "merge_requests"."target_branch" = 'master';
Query plan
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Bitmap Heap Scan on merge_requests (cost=4.63..76.76 rows=46 width=763) (actual time=0.069..0.248 rows=47 loops=1)
Recheck Cond: ((target_branch)::text = 'master'::text)
Heap Blocks: exact=32
-> Bitmap Index Scan on index_merge_requests_on_target_branch (cost=0.00..4.62 rows=46 width=0) (actual time=0.047..0.047 rows=55 loops=1)
Index Cond: ((target_branch)::text = 'master'::text)
Planning time: 7.204 ms
Execution time: 0.659 ms
Load target branches for autocomplete
Query
SELECT "merge_requests"."target_branch"
FROM "merge_requests"
WHERE "merge_requests"."target_project_id" = 1
GROUP BY "merge_requests"."target_branch"
ORDER BY MAX(merge_requests.updated_at) DESC LIMIT 100;
Query plan
QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------- Limit (cost=100.25..100.50 rows=100 width=24) (actual time=1.098..1.115 rows=55 loops=1) -> Sort (cost=100.25..100.59 rows=134 width=24) (actual time=1.094..1.102 rows=55 loops=1) Sort Key: (max(updated_at)) DESC Sort Method: quicksort Memory: 29kB -> HashAggregate (cost=94.18..95.52 rows=134 width=24) (actual time=1.008..1.018 rows=55 loops=1) Group Key: target_branch -> Seq Scan on merge_requests (cost=0.00..92.00 rows=436 width=24) (actual time=0.016..0.782 rows=435 loops=1) Filter: (target_project_id = 1) Rows Removed by Filter: 513 Planning time: 6.465 ms Execution time: 1.567 msWhy was this MR needed?
Screenshots (if relevant)
Does this MR meet the acceptance criteria?
-
Changelog entry added, if necessary -
Documentation created/updated -
API support added -
Tests added for this feature/bug - Review
-
Has been reviewed by UX -
Has been reviewed by Frontend -
Has been reviewed by Backend -
Has been reviewed by Database
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Squashed related commits together -
Internationalization required/considered
What are the relevant issue numbers?
Closes #33831 (closed)
Edited by Chris Peressini