From a40283cdb2d33f47dba4c2cd8fd82dc675dfe4e7 Mon Sep 17 00:00:00 2001 From: Muflone Date: Tue, 20 Aug 2024 17:54:56 +0200 Subject: [PATCH] fix: reduce the number of subqueries against User by loading eagerly the Users from PackageComaintainer --- aurweb/pkgbase/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aurweb/pkgbase/util.py b/aurweb/pkgbase/util.py index 7784638c..7b8ed700 100644 --- a/aurweb/pkgbase/util.py +++ b/aurweb/pkgbase/util.py @@ -2,6 +2,7 @@ from typing import Any from fastapi import Request from sqlalchemy import and_ +from sqlalchemy.orm import joinedload from aurweb import config, db, defaults, l10n, time, util from aurweb.models import PackageBase, User @@ -40,7 +41,7 @@ def make_context( context["pkgbase"] = pkgbase context["comaintainers"] = [ c.User - for c in pkgbase.comaintainers.order_by( + for c in pkgbase.comaintainers.options(joinedload(PackageComaintainer.User)).order_by( PackageComaintainer.Priority.asc() ).all() ]