create indices in magneticow rather than magneticod (rationale below)
It's better to create indices in magneticow rather than magneticod, because magneticod does NOT need them, but magneticow does.
This commit is contained in:
parent
c4b4773fdd
commit
e624837059
@ -50,14 +50,12 @@ class Database:
|
||||
"total_size INTEGER NOT NULL CHECK(total_size > 0),"
|
||||
"discovered_on INTEGER NOT NULL CHECK(discovered_on > 0)"
|
||||
");")
|
||||
db_conn.execute("CREATE INDEX IF NOT EXISTS info_hash_index ON torrents (info_hash);")
|
||||
db_conn.execute("CREATE TABLE IF NOT EXISTS files ("
|
||||
"id INTEGER PRIMARY KEY,"
|
||||
"torrent_id INTEGER REFERENCES torrents ON DELETE CASCADE ON UPDATE RESTRICT,"
|
||||
"size INTEGER NOT NULL,"
|
||||
"path TEXT NOT NULL"
|
||||
");")
|
||||
db_conn.execute("CREATE INDEX IF NOT EXISTS file_info_hash_index ON files (torrent_id);")
|
||||
|
||||
return db_conn
|
||||
|
||||
|
@ -322,6 +322,8 @@ def initialize_magneticod_db() -> None:
|
||||
magneticod_db.execute("PRAGMA journal_mode=WAL;")
|
||||
|
||||
magneticod_db.execute("CREATE INDEX IF NOT EXISTS discovered_on_index ON torrents (discovered_on);")
|
||||
magneticod_db.execute("CREATE INDEX IF NOT EXISTS info_hash_index ON torrents (info_hash);")
|
||||
magneticod_db.execute("CREATE INDEX IF NOT EXISTS file_info_hash_index ON files (torrent_id);")
|
||||
|
||||
magneticod_db.execute("CREATE VIRTUAL TABLE temp.fts_torrents USING fts4(name);")
|
||||
magneticod_db.execute("INSERT INTO fts_torrents (docid, name) SELECT id, name FROM torrents;")
|
||||
|
Loading…
Reference in New Issue
Block a user