From 2710b140e7e0cd942cfbadd805cd954987201011 Mon Sep 17 00:00:00 2001 From: Michael Kaiser Date: Thu, 23 May 2024 16:18:34 +0200 Subject: [PATCH] performance tuning of the database access for much faster api calls --- codeGrader/backend/db/Exercise.py | 2 +- codeGrader/backend/db/Subject.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/codeGrader/backend/db/Exercise.py b/codeGrader/backend/db/Exercise.py index be449d3..8dc28be 100644 --- a/codeGrader/backend/db/Exercise.py +++ b/codeGrader/backend/db/Exercise.py @@ -78,7 +78,7 @@ class Exercise(Base): passive_deletes=True, lazy="subquery", join_depth=3, - backref=backref("TaskExercise", lazy="joined", join_depth=3) + backref=backref("TaskExercise", lazy="subquery", join_depth=3) ) def get_profile(self): diff --git a/codeGrader/backend/db/Subject.py b/codeGrader/backend/db/Subject.py index 35dd302..9ecb0e4 100644 --- a/codeGrader/backend/db/Subject.py +++ b/codeGrader/backend/db/Subject.py @@ -72,7 +72,8 @@ class Subject(Base): cascade="all", passive_deletes=True, lazy="subquery", - backref=backref("ExerciseSubject", lazy="joined") + join_depth=1, + backref=backref("ExerciseSubject", lazy="joined", join_depth=1) ) memberships = relationship( @@ -83,7 +84,7 @@ class Subject(Base): cascade="all", passive_deletes=True, lazy="noload", - backref=backref("MembershipSubject", lazy="joined", join_depth=3) + backref=backref("MembershipSubject", lazy="joined", join_depth=2) ) def get_profile(self) -> dict: