Much improved performance adding tracks

This commit is contained in:
Keith Edmunds 2023-10-01 15:09:41 +01:00
parent c1fae2f91a
commit b2f826dfcc

View File

@ -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()