From 3077a1378b5575cf24651bf70cfdffa6b6ce13b4 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 3 Sep 2020 22:51:58 +1000 Subject: [PATCH] syncjournaldb: index e2eMangledName column in metadata Add an index on the e2eMangledName column in the metadata table to speed up file sync by orders of magnitude on directories with a large number of files. Signed-off-by: Jan Schmidt --- src/common/syncjournaldb.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index d13f855d58..1666c4f82b 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -745,6 +745,15 @@ bool SyncJournalDb::updateMetadataTableStructure() commitInternal("update database structure: add contentChecksum col for uploadinfo"); } + if (true) { + SqlQuery query(_db); + query.prepare("CREATE INDEX IF NOT EXISTS metadata_e2e_id ON metadata(e2eMangledName);"); + if (!query.exec()) { + sqlFail("updateMetadataTableStructure: create index e2eMangledName", query); + re = false; + } + commitInternal("update database structure: add e2eMangledName index"); + } return re; }