Skip to content

Commit ea288e9

Browse files
committed
perf: create sqlite indexes for common columns
1 parent 2332343 commit ea288e9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,20 @@ def open_sqlite_library(self, library_dir: Path, is_new: bool) -> LibraryStatus:
555555
# Convert file extension list to ts_ignore file, if a .ts_ignore file does not exist
556556
self.migrate_sql_to_ts_ignore(library_dir)
557557

558+
session.execute(
559+
text("CREATE INDEX IF NOT EXISTS idx_tags_name_shorthand ON tags (name, shorthand)")
560+
)
561+
session.execute(
562+
text(
563+
"CREATE INDEX IF NOT EXISTS idx_tag_parents_child_id ON tag_parents (child_id)"
564+
)
565+
)
566+
session.execute(
567+
text(
568+
"CREATE INDEX IF NOT EXISTS idx_tag_entries_entry_id ON tag_entries (entry_id)"
569+
)
570+
)
571+
558572
# Update DB_VERSION
559573
if loaded_db_version < DB_VERSION:
560574
self.set_version(DB_VERSION_CURRENT_KEY, DB_VERSION)

0 commit comments

Comments
 (0)