mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 07:39:10 +00:00
add performance logging
This commit is contained in:
@@ -540,6 +540,7 @@ class Library:
|
||||
with Session(self.engine, expire_on_commit=False) as session:
|
||||
statement = select(Entry)
|
||||
|
||||
start = time.time()
|
||||
if search.ast:
|
||||
statement = (
|
||||
statement.outerjoin(Entry.tag_box_fields)
|
||||
@@ -547,6 +548,8 @@ class Library:
|
||||
.outerjoin(TagAlias)
|
||||
.where(SQLBoolExpressionBuilder().visit(search.ast))
|
||||
)
|
||||
end = time.time()
|
||||
logger.info(f"Building SQL Done in {format_timespan(end-start)}")
|
||||
|
||||
extensions = self.prefs(LibraryPrefs.EXTENSION_LIST)
|
||||
is_exclude_list = self.prefs(LibraryPrefs.IS_EXCLUDE_LIST)
|
||||
@@ -568,7 +571,10 @@ class Library:
|
||||
query_count = select(func.count(distinct(aliased_statement.c.id))).select_from(
|
||||
aliased_statement
|
||||
)
|
||||
start = time.time()
|
||||
count_all: int = session.execute(query_count).scalar()
|
||||
end = time.time()
|
||||
logger.info(f"SQL Count Query done in {format_timespan(end-start)}")
|
||||
|
||||
statement = statement.limit(search.limit).offset(search.offset)
|
||||
|
||||
@@ -578,10 +584,13 @@ class Library:
|
||||
query_full=str(statement.compile(compile_kwargs={"literal_binds": True})),
|
||||
)
|
||||
|
||||
start = time.time()
|
||||
res = SearchResult(
|
||||
total_count=count_all,
|
||||
items=list(session.scalars(statement).unique()),
|
||||
)
|
||||
end = time.time()
|
||||
logger.info(f"SQL Results Query done in {format_timespan(end-start)}")
|
||||
|
||||
session.expunge_all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user