From a0edaa9210642f23ef3ea4984c6d6f77cbbba878 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sun, 23 Apr 2017 22:32:50 -0700 Subject: Cache Routable#full_path in RequestStore to reduce duplicate route loads We see in #27387 that a call to `polymorphic_path` will cause duplicate SELECT route calls for each merge request in a milestone. This happens because calling `project.namespace.becomes(Namespace)` will instantiate a new instance of a Namespace for each merge request, which causes a N+1 query on the routes table. This change caches the state of the route by the specific class and ID, which dramatically eliminates duplicate work. --- changelogs/unreleased/sh-optimize-duplicate-routable-full-path.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelogs/unreleased/sh-optimize-duplicate-routable-full-path.yml (limited to 'changelogs') diff --git a/changelogs/unreleased/sh-optimize-duplicate-routable-full-path.yml b/changelogs/unreleased/sh-optimize-duplicate-routable-full-path.yml new file mode 100644 index 00000000000..b1ef00f09b2 --- /dev/null +++ b/changelogs/unreleased/sh-optimize-duplicate-routable-full-path.yml @@ -0,0 +1,4 @@ +--- +title: Cache Routable#full_path in RequestStore to reduce duplicate route loads +merge_request: +author: -- cgit v1.2.1