Optimization: don't load a User when user_id is missing

What does this MR do and why?

Contributes to #482942 (closed)

Problem

We try to load a user even when ssh_known_hosts_verified_by_id is missing. It triggers unnecessary requests to the database.

Solution

Verify if the id is set before making a request.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
Screenshot_2024-10-14_at_17.44.45 Screenshot_2024-10-14_at_17.45.16

How to set up and validate locally

  1. Visit http://gdk.test:3000/gitlab-org/gitlab-test/-/settings/repository#js-push-remote-settings
  2. Check performance bar queries
  3. Query like SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT 1 should be missing there.

Numbered steps to set up and validate the change are strongly suggested.

Edited by Vasilii Iakliushin

Merge request reports

Loading