Skip to content

Fix N + 1 for MilestonesController#merge_requests

Igor Drozdov requested to merge id-preload-associations-to-milestones-mrs into master

What does this MR do?

Preload merge requests associations to avoid N + 1 on https://gitlab.com/gitlab-org/sample-data-templates/serenity-valley/-/milestones/1#tab-merge-requests

Before

4.705ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (1)) AND (NOT EXISTS (SELECT TRUE FROM merge_request_assignees WHERE merge_request_id = merge_requests.id)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_667280'*/ 
3.355ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 36 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
3.115ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (1)) AND (EXISTS (SELECT TRUE FROM merge_request_assignees WHERE merge_request_id = merge_requests.id)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_667280'*/ 
2.715ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 5 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.595ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 6 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.572ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 5 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.543ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (3)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_667500'*/ 
2.519ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 6 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.409ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (2)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_667280'*/ 
2.322ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 48 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.157ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 45 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.079ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 53 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.074ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 36 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.012ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 53 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
2.01ms	
SELECT "users".* FROM "users" INNER JOIN "merge_request_assignees" ON "users"."id" = "merge_request_assignees"."user_id" WHERE "merge_request_assignees"."merge_request_id" = 45 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:24:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
1.773ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 22 AND "routes"."source_type" = 'Namespace' LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/models/concerns/routable.rb:103:in `full_path'*/ 
1.735ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/finders/issuable_finder/params.rb:118:in `block in project'*/ 
1.576ms	
SELECT "milestones".* FROM "milestones" WHERE "milestones"."project_id" = 2 AND "milestones"."iid" = 2 LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/controllers/projects/milestones_controller.rb:128:in `milestone'*/ 
1.574ms	
SELECT "labels".* FROM "labels" INNER JOIN "label_links" ON "labels"."id" = "label_links"."label_id" WHERE "label_links"."target_id" = 48 AND "label_links"."target_type" = 'MergeRequest' ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuable.html.haml:20:in `_app_views_shared_milestones__issuable_html_haml__2236149415580073627_667320'*/ 
1.507ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = 22 AND "namespaces"."type" = 'Group' LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/ee/app/policies/ee/project_policy.rb:346:in `block (2 levels) in <module:ProjectPolicy>'*/ 
1.483ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 22 LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/config/routes.rb:326:in `block (3 levels) in <main>'*/ 
1.351ms	
SELECT "projects"."id" AS t0_r0, "projects"."name" AS t0_r1, "projects"."path" AS t0_r2, "projects"."description" AS t0_r3, "projects"."created_at" AS t0_r4, "projects"."updated_at" AS t0_r5, "projects"."creator_id" AS t0_r6, "projects"."namespace_id" AS t0_r7, "projects"."last_activity_at" AS t0_r8, "projects"."import_url" AS t0_r9, "projects"."visibility_level" AS t0_r10, "projects"."archived" AS t0_r11, "projects"."avatar" AS t0_r12, "projects"."merge_requests_template" AS t0_r13, "projects"."star_count" AS t0_r14, "projects"."merge_requests_rebase_enabled" AS t0_r15, "projects"."import_type" AS t0_r16, "projects"."import_source" AS t0_r17, "projects"."approvals_before_merge" AS t0_r18, "projects"."reset_approvals_on_push" AS t0_r19, "projects"."merge_requests_ff_only_enabled" AS t0_r20, "projects"."issues_template" AS t0_r21, "projects"."mirror" AS t0_r22, "projects"."mirror_last_update_at" AS t0_r23, "projects"."mirror_last_successful_update_at" AS t0_r24, "projects"."mirror_user_id" AS t0_r25, "projects"."shared_runners_enabled" AS t0_r26, "projects"."runners_token" AS t0_r27, "projects"."build_coverage_regex" AS t0_r28, "projects"."build_allow_git_fetch" AS t0_r29, "projects"."build_timeout" AS t0_r30, "projects"."mirror_trigger_builds" AS t0_r31, "projects"."pending_delete" AS t0_r32, "projects"."public_builds" AS t0_r33, "projects"."last_repository_check_failed" AS t0_r34, "projects"."last_repository_check_at" AS t0_r35, "projects"."container_registry_enabled" AS t0_r36, "projects"."only_allow_merge_if_pipeline_succeeds" AS t0_r37, "projects"."has_external_issue_tracker" AS t0_r38, "projects"."repository_storage" AS t0_r39, "projects"."repository_read_only" AS t0_r40, "projects"."request_access_enabled" AS t0_r41, "projects"."has_external_wiki" AS t0_r42, "projects"."ci_config_path" AS t0_r43, "projects"."lfs_enabled" AS t0_r44, "projects"."description_html" AS t0_r45, "projects"."only_allow_merge_if_all_discussions_are_resolved" AS t0_r46, "projects"."repository_size_limit" AS t0_r47, "projects"."printing_merge_request_link_enabled" AS t0_r48, "projects"."auto_cancel_pending_pipelines" AS t0_r49, "projects"."service_desk_enabled" AS t0_r50, "projects"."cached_markdown_version" AS t0_r51, "projects"."delete_error" AS t0_r52, "projects"."last_repository_updated_at" AS t0_r53, "projects"."disable_overriding_approvers_per_merge_request" AS t0_r54, "projects"."storage_version" AS t0_r55, "projects"."resolve_outdated_diff_discussions" AS t0_r56, "projects"."remote_mirror_available_overridden" AS t0_r57, "projects"."only_mirror_protected_branches" AS t0_r58, "projects"."pull_mirror_available_overridden" AS t0_r59, "projects"."jobs_cache_index" AS t0_r60, "projects"."external_authorization_classification_label" AS t0_r61, "projects"."mirror_overwrites_diverged_branches" AS t0_r62, "projects"."pages_https_only" AS t0_r63, "projects"."external_webhook_token" AS t0_r64, "projects"."packages_enabled" AS t0_r65, "projects"."merge_requests_author_approval" AS t0_r66, "projects"."pool_repository_id" AS t0_r67, "projects"."runners_token_encrypted" AS t0_r68, "projects"."bfg_object_map" AS t0_r69, "projects"."detected_repository_languages" AS t0_r70, "projects"."merge_requests_disable_committers_approval" AS t0_r71, "projects"."require_password_to_approve" AS t0_r72, "projects"."emails_disabled" AS t0_r73, "projects"."max_pages_size" AS t0_r74, "projects"."max_artifacts_size" AS t0_r75, "projects"."pull_mirror_branch_prefix" AS t0_r76, "projects"."remove_source_branch_after_merge" AS t0_r77, "projects"."marked_for_deletion_at" AS t0_r78, "projects"."marked_for_deletion_by_user_id" AS t0_r79, "projects"."autoclose_referenced_issues" AS t0_r80, "projects"."suggestion_commit_message" AS t0_r81, "routes"."id" AS t1_r0, "routes"."source_id" AS t1_r1, "routes"."source_type" AS t1_r2, "routes"."path" AS t1_r3, "routes"."created_at" AS t1_r4, "routes"."updated_at" AS t1_r5, "routes"."name" AS t1_r6 FROM "projects" LEFT OUTER JOIN "routes" ON "routes"."source_type" = 'Project' AND "routes"."source_id" = "projects"."id" WHERE "routes"."path" = 'gitlab-org/gitlab-shell' LIMIT 1 
Cached
1.246ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
1.224ms	
SELECT "project_features".* FROM "project_features" WHERE "project_features"."project_id" = 2 LIMIT 1 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/models/project.rb:394:in `feature_available?'*/ 
1.19ms	
SELECT "ip_restrictions".* FROM "ip_restrictions" WHERE "ip_restrictions"."group_id" = 22 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/ee/lib/gitlab/ip_restriction/enforcer.rb:31:in `allows_address?'*/ 
1.177ms	
SELECT "licenses".* FROM "licenses" ORDER BY "licenses"."id" DESC LIMIT 100 /*application:web,correlation_id:01F243DN4BCX6A9KTV5F3WX3T1,endpoint_id:Projects::MilestonesController#merge_requests,line:/ee/app/models/license.rb:297:in `load_license'*/ 
1.173ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
1.126ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
1.109ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
1.027ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
0.995ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 
Cached
After

22.65ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" IN (22, 1) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
21.658ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 
Cached
8.888ms	
SELECT "merge_request_assignees".* FROM "merge_request_assignees" WHERE "merge_request_assignees"."merge_request_id" IN (53, 48, 45) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
6.561ms	
SELECT "labels".* FROM "labels" WHERE "labels"."id" IN (2, 10, 7, 77, 76, 78, 6, 4, 1, 75) ORDER BY "labels"."title" ASC /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
6.163ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Namespace' AND "routes"."source_id" IN (1, 22) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
4.176ms	
SELECT "label_links".* FROM "label_links" WHERE "label_links"."target_type" = 'MergeRequest' AND "label_links"."target_id" IN (36, 6, 5) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
4.119ms	
SELECT "label_links".* FROM "label_links" WHERE "label_links"."target_type" = 'MergeRequest' AND "label_links"."target_id" IN (53, 48, 45) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
4.09ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Project' AND "routes"."source_id" IN (2, 16) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
3.175ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (3)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885360'*/ 
3.061ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 22 LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/config/routes.rb:326:in `block (3 levels) in <main>'*/ 
2.876ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (2)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
2.659ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" IN (16, 2) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
2.638ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (1)) AND (EXISTS (SELECT TRUE FROM merge_request_assignees WHERE merge_request_id = merge_requests.id)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
2.637ms	
SELECT merge_requests.*, (SELECT MIN("label_priorities"."priority") FROM "labels" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" WHERE (label_priorities.project_id = merge_requests.target_project_id) AND (label_links.target_id = merge_requests.id) AND "label_links"."target_type" = 'MergeRequest') AS highest_priority FROM "merge_requests" WHERE "merge_requests"."target_project_id" = 2 AND "merge_requests"."milestone_id" = 7 AND ("merge_requests"."state_id" IN (1)) AND (NOT EXISTS (SELECT TRUE FROM merge_request_assignees WHERE merge_request_id = merge_requests.id)) GROUP BY "merge_requests"."id" ORDER BY highest_priority ASC NULLS LAST, "merge_requests"."id" DESC /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
2.245ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
2.001ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 22 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
1.917ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Namespace' AND "routes"."source_id" = 22 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
1.714ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 22 AND "routes"."source_type" = 'Namespace' LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/models/concerns/routable.rb:103:in `full_path'*/ 
1.657ms	
SELECT "users".* FROM "users" WHERE "users"."id" IN (12, 1) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
1.631ms	
SELECT "merge_request_assignees".* FROM "merge_request_assignees" WHERE "merge_request_assignees"."merge_request_id" IN (36, 6, 5) /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
1.605ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Project' AND "routes"."source_id" = 2 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/views/shared/milestones/_issuables.html.haml:11:in `_app_views_shared_milestones__issuables_html_haml__864339097987519666_885320'*/ 
1.42ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = 'Group' AND "namespaces"."id" = 22 AND "namespaces"."type" = 'Group' LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/ee/app/policies/ee/project_policy.rb:346:in `block (2 levels) in <module:ProjectPolicy>'*/ 
1.393ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Namespace' AND "routes"."source_id" = 22 
Cached
1.363ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/finders/issuable_finder/params.rb:118:in `block in project'*/ 
1.323ms	
SELECT "projects"."id" AS t0_r0, "projects"."name" AS t0_r1, "projects"."path" AS t0_r2, "projects"."description" AS t0_r3, "projects"."created_at" AS t0_r4, "projects"."updated_at" AS t0_r5, "projects"."creator_id" AS t0_r6, "projects"."namespace_id" AS t0_r7, "projects"."last_activity_at" AS t0_r8, "projects"."import_url" AS t0_r9, "projects"."visibility_level" AS t0_r10, "projects"."archived" AS t0_r11, "projects"."avatar" AS t0_r12, "projects"."merge_requests_template" AS t0_r13, "projects"."star_count" AS t0_r14, "projects"."merge_requests_rebase_enabled" AS t0_r15, "projects"."import_type" AS t0_r16, "projects"."import_source" AS t0_r17, "projects"."approvals_before_merge" AS t0_r18, "projects"."reset_approvals_on_push" AS t0_r19, "projects"."merge_requests_ff_only_enabled" AS t0_r20, "projects"."issues_template" AS t0_r21, "projects"."mirror" AS t0_r22, "projects"."mirror_last_update_at" AS t0_r23, "projects"."mirror_last_successful_update_at" AS t0_r24, "projects"."mirror_user_id" AS t0_r25, "projects"."shared_runners_enabled" AS t0_r26, "projects"."runners_token" AS t0_r27, "projects"."build_coverage_regex" AS t0_r28, "projects"."build_allow_git_fetch" AS t0_r29, "projects"."build_timeout" AS t0_r30, "projects"."mirror_trigger_builds" AS t0_r31, "projects"."pending_delete" AS t0_r32, "projects"."public_builds" AS t0_r33, "projects"."last_repository_check_failed" AS t0_r34, "projects"."last_repository_check_at" AS t0_r35, "projects"."container_registry_enabled" AS t0_r36, "projects"."only_allow_merge_if_pipeline_succeeds" AS t0_r37, "projects"."has_external_issue_tracker" AS t0_r38, "projects"."repository_storage" AS t0_r39, "projects"."repository_read_only" AS t0_r40, "projects"."request_access_enabled" AS t0_r41, "projects"."has_external_wiki" AS t0_r42, "projects"."ci_config_path" AS t0_r43, "projects"."lfs_enabled" AS t0_r44, "projects"."description_html" AS t0_r45, "projects"."only_allow_merge_if_all_discussions_are_resolved" AS t0_r46, "projects"."repository_size_limit" AS t0_r47, "projects"."printing_merge_request_link_enabled" AS t0_r48, "projects"."auto_cancel_pending_pipelines" AS t0_r49, "projects"."service_desk_enabled" AS t0_r50, "projects"."cached_markdown_version" AS t0_r51, "projects"."delete_error" AS t0_r52, "projects"."last_repository_updated_at" AS t0_r53, "projects"."disable_overriding_approvers_per_merge_request" AS t0_r54, "projects"."storage_version" AS t0_r55, "projects"."resolve_outdated_diff_discussions" AS t0_r56, "projects"."remote_mirror_available_overridden" AS t0_r57, "projects"."only_mirror_protected_branches" AS t0_r58, "projects"."pull_mirror_available_overridden" AS t0_r59, "projects"."jobs_cache_index" AS t0_r60, "projects"."external_authorization_classification_label" AS t0_r61, "projects"."mirror_overwrites_diverged_branches" AS t0_r62, "projects"."pages_https_only" AS t0_r63, "projects"."external_webhook_token" AS t0_r64, "projects"."packages_enabled" AS t0_r65, "projects"."merge_requests_author_approval" AS t0_r66, "projects"."pool_repository_id" AS t0_r67, "projects"."runners_token_encrypted" AS t0_r68, "projects"."bfg_object_map" AS t0_r69, "projects"."detected_repository_languages" AS t0_r70, "projects"."merge_requests_disable_committers_approval" AS t0_r71, "projects"."require_password_to_approve" AS t0_r72, "projects"."emails_disabled" AS t0_r73, "projects"."max_pages_size" AS t0_r74, "projects"."max_artifacts_size" AS t0_r75, "projects"."pull_mirror_branch_prefix" AS t0_r76, "projects"."remove_source_branch_after_merge" AS t0_r77, "projects"."marked_for_deletion_at" AS t0_r78, "projects"."marked_for_deletion_by_user_id" AS t0_r79, "projects"."autoclose_referenced_issues" AS t0_r80, "projects"."suggestion_commit_message" AS t0_r81, "routes"."id" AS t1_r0, "routes"."source_id" AS t1_r1, "routes"."source_type" AS t1_r2, "routes"."path" AS t1_r3, "routes"."created_at" AS t1_r4, "routes"."updated_at" AS t1_r5, "routes"."name" AS t1_r6 FROM "projects" LEFT OUTER JOIN "routes" ON "routes"."source_type" = 'Project' AND "routes"."source_id" = "projects"."id" WHERE "routes"."path" = 'gitlab-org/gitlab-shell' LIMIT 1 
Cached
1.245ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Namespace' AND "routes"."source_id" = 22 
Cached
1.211ms	
SELECT "milestones".* FROM "milestones" WHERE "milestones"."project_id" = 2 AND "milestones"."iid" = 2 LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/controllers/projects/milestones_controller.rb:128:in `milestone'*/ 
1.203ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Project' AND "routes"."source_id" = 2 
Cached
1.147ms	
SELECT "ip_restrictions".* FROM "ip_restrictions" WHERE "ip_restrictions"."group_id" = 22 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/ee/lib/gitlab/ip_restriction/enforcer.rb:31:in `allows_address?'*/ 
1.089ms	
SELECT "project_features".* FROM "project_features" WHERE "project_features"."project_id" = 2 LIMIT 1 /*application:web,correlation_id:01F243PZGW0FJ7WK5E22KAV78Z,endpoint_id:Projects::MilestonesController#merge_requests,line:/app/models/project.rb:394:in `feature_available?'*/ 
1.064ms	
SELECT "routes".* FROM "routes" WHERE "routes"."source_type" = 'Project' AND "routes"."source_id" = 2 
Cached
1.03ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 22 
Cached
0.995ms	
SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."id" = 22 
Cached
0.96ms	
SELECT "projects".* FROM "projects" WHERE "projects"."id" = 2 
Cached
Edited by Igor Drozdov

Merge request reports

Loading