feat: reduce time consumption of counting total results massively

This commit is contained in:
Jann Stute
2025-01-02 01:49:22 +01:00
parent 8898289450
commit 30af514681

View File

@@ -573,7 +573,9 @@ class Library:
statement = statement.distinct(Entry.id)
query_count = select(func.count()).select_from(statement.alias("entries"))
# only selecting the id and counting on that is quicker when using the ORM
counting_statement = select(statement.alias("result").c[0])
query_count = select(func.count()).select_from(counting_statement.alias("entries"))
count_all: int = session.execute(query_count).scalar()
statement = statement.limit(search.limit).offset(search.offset)