Geo: Calling Gitlab::Geo.primary? causes unnecessary DB queries
When Geo is active, because of the after_initialize :build_dependents line in GeoNode, every time we instantiate an object we add additional queries:
GeoNode Exists (6.6ms) SELECT 1 AS one FROM "geo_nodes" LIMIT 1
GeoNode Load (0.4ms) SELECT "geo_nodes".* FROM "geo_nodes" WHERE "geo_nodes"."host" = $1 AND "geo_nodes"."port" = $2 AND "geo_nodes"."relative_url_root" = $3 LIMIT 1 [["host", "stanhu-geo-secondary"], ["port", 80], ["relative_url_root", ""]]
GeoNodeKey Load (0.4ms) SELECT "keys".* FROM "keys" WHERE "keys"."type" IN ('GeoNodeKey') AND "keys"."id" = $1 ORDER BY "keys"."id" DESC LIMIT 1 [["id", 3]]
SystemHook Load (0.5ms) SELECT "web_hooks".* FROM "web_hooks" WHERE "web_hooks"."type" IN ('SystemHook') AND "web_hooks"."id" = $1 ORDER BY "web_hooks"."id" DESC LIMIT 1 [["id", 3]]
This could lead to a lot of overhead if we start transferring lots of files that require authentication.
Edited by Mike Lockhart | GitLab