From b2f826dfccf6cacd210ff3f53894dfe1191d1d6b Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 1 Oct 2023 15:09:41 +0100 Subject: [PATCH] Much improved performance adding tracks --- app/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 60a1878..78185df 100644 --- a/app/models.py +++ b/app/models.py @@ -718,7 +718,11 @@ class Tracks(Base): """Search case-insenstively for titles containing str""" return ( session.execute( - select(cls).where(cls.title.like(f"{text}%")).order_by(cls.title) + select(cls) + .join(Playdates, isouter=True) + .where(cls.title.like(f"{text}%")) + .group_by(cls.title) + .order_by(cls.title) ) .scalars() .all()