Skip to content

Improve hooks view performance

Andy Schoenen requested to merge improve_webhooks_view_performance into master

What does this MR do?

It removes two unnecessary SQL query: SELECT COUNT(*) FROM "web_hooks" and SELECT 1 AS one FROM "web_hooks"

Before

  ↳ app/views/projects/hooks/index.html.haml:10
  Route Load (0.4ms)  SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 1 AND "routes"."source_type" = 'Namespace' LIMIT 1
  ↳ app/models/concerns/routable.rb:77:in `full_path'
  Rendered shared/web_hooks/_form.html.haml (Duration: 12.1ms | Allocations: 23714)
   (0.5ms)  SELECT COUNT(*) FROM "web_hooks" WHERE "web_hooks"."type" = 'ProjectHook' AND "web_hooks"."project_id" = 19
  ↳ app/views/shared/web_hooks/_index.html.haml:6
  ProjectHook Exists? (0.6ms)  SELECT 1 AS one FROM "web_hooks" WHERE "web_hooks"."type" = 'ProjectHook' AND "web_hooks"."project_id" = 19 LIMIT 1
  ↳ app/views/shared/web_hooks/_index.html.haml:8
  ProjectHook Load (1.2ms)  SELECT "web_hooks".* FROM "web_hooks" WHERE "web_hooks"."type" = 'ProjectHook' AND "web_hooks"."project_id" = 19
  ↳ app/views/shared/web_hooks/_index.html.haml:10

After:

  ↳ app/views/projects/hooks/index.html.haml:10
  Route Load (0.3ms)  SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 1 AND "routes"."source_type" = 'Namespace' LIMIT 1
  ↳ app/models/concerns/routable.rb:77:in `full_path'
  Rendered shared/web_hooks/_form.html.haml (Duration: 1.6ms | Allocations: 1947)
  ProjectHook Load (0.3ms)  SELECT "web_hooks".* FROM "web_hooks" WHERE "web_hooks"."type" = 'ProjectHook' AND "web_hooks"."project_id" = 19
  ↳ app/views/shared/web_hooks/_index.html.haml:6

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • [-] Label as security and @ mention @gitlab-com/gl-security/appsec
  • [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports