1000+ SQL queries in PipelinesController#index.json
From https://gitlab.com/gitlab-org/gitlab/pipelines:
Attached is the performance bar data:
pipelines_perf_bar_1576475008083.json.zip
The breakdown seems to be:
# cat /tmp/pipelines_perf_bar_1576475008083.json| jq -C | grep sql | sort -nr | uniq -c | sort -nr | less -R
260 "sql": "SELECT \"protected_environments\".* FROM \"protected_environments\" WHERE \"protected_environments\".\"project_id\" = 278964 AND \"protected_environments\".\"name\" IS NULL LIMIT 1",
208 "sql": "SELECT \"projects\".* FROM \"projects\" WHERE \"projects\".\"id\" = 278964 LIMIT 1",
204 "sql": "SELECT \"routes\".* FROM \"routes\" WHERE \"routes\".\"source_id\" = 9970 AND \"routes\".\"source_type\" = 'Namespace' LIMIT 1",
203 "sql": "SELECT \"namespaces\".* FROM \"namespaces\" WHERE \"namespaces\".\"id\" = 9970 LIMIT 1",
78 "sql": "SELECT \"routes\".* FROM \"routes\" WHERE \"routes\".\"source_id\" = 278964 AND \"routes\".\"source_type\" = 'Project' LIMIT 1",
38 "sql": "SELECT \"environments\".* FROM \"environments\" WHERE \"environments\".\"name\" = 'review/auto-cleanup' AND \"environments\".\"project_id\" = 278964 LIMIT 1",
26 "app/models/ci/pipeline.rb:372:in `legacy_stages_using_sql'",
16 "sql": "SELECT \"ci_pipelines\".* FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"id\" = 103266983 LIMIT 1",
10 "sql": "SELECT \"protected_branches\".* FROM \"protected_branches\" WHERE \"protected_branches\".\"project_id\" = 278964",
10 "sql": "SELECT \"ci_pipelines\".* FROM \"ci_pipelines\" WHERE \"ci_pipelines\".\"id\" = 103268758 LIMIT 1",
8 "sql": "SELECT \"ci_variables\".* FROM \"ci_variables\" WHERE \"ci_variables\".\"project_id\" = 278964 AND \"ci_variables\".\"protected\" = FALSE AND \"ci_variables\".\"environment_scope\" = '*'",
8 "sql": "SELECT \"ci_group_variables\".* FROM \"ci_group_variables\" WHERE \"ci_group_variables\".\"group_id\" = 9970 AND \"ci_group_variables\".\"protected\" = FALSE",
8 "sql": "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = 3945330 LIMIT 1",
8 "sql": "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = 3397881 LIMIT 1",
8 "sql": "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = 2880930 LIMIT 1",
6 "sql": "SELECT \"projects\".* FROM \"projects\" WHERE \"projects\".\"id\" = 278964",
6 "sql": "SELECT \"users\".* FROM \"users\" WHERE \"users\".\"id\" = 4092171 LIMIT 1",
5 "sql": "SELECT \"saml_providers\".* FROM \"saml_providers\" WHERE \"saml_providers\".\"group_id\" = 9970 LIMIT 1",
5 "sql": "SELECT \"project_features\".* FROM \"project_features\" WHERE \"project_features\".\"project_id\" = 278964 LIMIT 1",
5 "sql": "SELECT \"namespaces\".* FROM \"namespaces\" WHERE \"namespaces\".\"type\" IN ('Group') AND \"namespaces\".\"id\" = 9970 AND \"namespaces\".\"type\" = 'Group' LIMIT 1",
4 "sql": "SELECT \"routes\".* FROM \"routes\" WHERE \"routes\".\"source_type\" = 'Namespace' AND \"routes\".\"source_id\" = 9970",
4 "sql": "SELECT \"namespaces\".* FROM \"namespaces\" WHERE \"namespaces\".\"id\" = 9970",
/cc: @matteeyah