Skip to content

Commit 12b6b53

Browse files
committed
fix (sql): Use more optimal SQL
1 parent 88d0b47 commit 12b6b53

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/tagstudio/core/library/alchemy/library.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,11 @@ def search_library(
10411041
ast = search.ast
10421042

10431043
if not search.show_hidden_entries:
1044-
statement = statement.where(~Entry.tags.any(Tag.is_hidden))
1044+
hidden_tag_ids = select(Tag.id).where(Tag.is_hidden)
1045+
hidden_entry_ids = select(TagEntry.entry_id).where(
1046+
TagEntry.tag_id.in_(hidden_tag_ids)
1047+
)
1048+
statement = statement.where(Entry.id.not_in(hidden_entry_ids))
10451049

10461050
if ast:
10471051
start_time = time.time()

0 commit comments

Comments
 (0)