From 7f861964eabd8d95af144afcbc0939d994877de8 Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Mon, 7 Oct 2019 16:40:38 +0200 Subject: [PATCH] logic: improved performance of clearing data from re-indexed files to be instant --- .../storage/sqlite/SqliteIndexStorage.cpp | 26 +++++++++++++++++++ .../data/storage/sqlite/SqliteIndexStorage.h | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp index de073318..9e1889b6 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.cpp @@ -1136,6 +1136,31 @@ std::vector> SqliteIndexStorage::getIndices( STORAGE_MODE_READ | STORAGE_MODE_CLEAR, SqliteDatabaseIndex("occurrence_source_location_id_index", "occurrence(source_location_id)") )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("element_component_foreign_key_index", "element_component(element_id)") + )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("edge_source_foreign_key_index", "edge(source_node_id)") + )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("edge_target_foreign_key_index", "edge(target_node_id)") + )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("source_location_foreign_key_index", "source_location(file_node_id)") + )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("occurrence_element_foreign_key_index", "occurrence(element_id)") + )); + indices.push_back(std::make_pair( + STORAGE_MODE_CLEAR, + SqliteDatabaseIndex("occurrence_source_location_foreign_key_index", "occurrence(source_location_id)") + )); + return indices; } @@ -1230,6 +1255,7 @@ void SqliteIndexStorage::setupTables() "CREATE TABLE IF NOT EXISTS filecontent(" "id INTERGER, " "content TEXT, " + "PRIMARY KEY(id), " "FOREIGN KEY(id) REFERENCES file(id)" "ON DELETE CASCADE " "ON UPDATE CASCADE);" diff --git a/src/lib/data/storage/sqlite/SqliteIndexStorage.h b/src/lib/data/storage/sqlite/SqliteIndexStorage.h index 681cb1d5..da04ccae 100644 --- a/src/lib/data/storage/sqlite/SqliteIndexStorage.h +++ b/src/lib/data/storage/sqlite/SqliteIndexStorage.h @@ -39,7 +39,7 @@ public: { STORAGE_MODE_READ = 1, STORAGE_MODE_WRITE = 2, - STORAGE_MODE_CLEAR = 4, + STORAGE_MODE_CLEAR = 4 }; SqliteIndexStorage(const FilePath& dbFilePath);