From be32e8893d48e8283192c82beaf9005d931fdd53 Mon Sep 17 00:00:00 2001 From: gvolfing Date: Tue, 19 Mar 2024 15:00:44 +0100 Subject: [PATCH] Create flags for enabling auto index creation --- config/flags.yaml | 8 ++++++++ src/flags/general.cpp | 8 ++++++++ src/flags/general.hpp | 4 ++++ src/memgraph.cpp | 10 ++++++++++ src/storage/v2/config.hpp | 12 ++++++++++-- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/config/flags.yaml b/config/flags.yaml index b551f90e4..3b5794643 100644 --- a/config/flags.yaml +++ b/config/flags.yaml @@ -119,6 +119,14 @@ modifications: value: "false" override: true + - name: "storage_enable_automatic_label_index_creation" + value: "false" + override: true + + - name: "storage_enable_automatic_edge_type_index_creation" + value: "false" + override: true + - name: "query_callable_mappings_path" value: "/etc/memgraph/apoc_compatibility_mappings.json" override: true diff --git a/src/flags/general.cpp b/src/flags/general.cpp index 37fa17b36..194f1123f 100644 --- a/src/flags/general.cpp +++ b/src/flags/general.cpp @@ -131,6 +131,14 @@ DEFINE_uint64(storage_recovery_thread_count, DEFINE_bool(storage_enable_schema_metadata, false, "Controls whether metadata should be collected about the resident labels and edge types."); +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +DEFINE_bool(storage_enable_automatic_label_index_creation, false, + "Controls whether label indexes on vertices should be created automatically."); + +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +DEFINE_bool(storage_enable_automatic_edge_type_index_creation, false, + "Controls whether edge-type indexes on relationships should be created automatically."); + // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DEFINE_bool(storage_delta_on_identical_property_update, true, "Controls whether updating a property with the same value should create a delta object."); diff --git a/src/flags/general.hpp b/src/flags/general.hpp index 52f51471d..873c96a51 100644 --- a/src/flags/general.hpp +++ b/src/flags/general.hpp @@ -85,6 +85,10 @@ DECLARE_uint64(storage_recovery_thread_count); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DECLARE_bool(storage_enable_schema_metadata); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +DECLARE_bool(storage_enable_automatic_label_index_creation); +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +DECLARE_bool(storage_enable_automatic_edge_type_index_creation); +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) DECLARE_bool(storage_delta_on_identical_property_update); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) diff --git a/src/memgraph.cpp b/src/memgraph.cpp index 9bf50131d..617b4cacc 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -333,8 +333,18 @@ int main(int argc, char **argv) { .wal_directory = FLAGS_data_directory + "/rocksdb_wal"}, .salient.items = {.properties_on_edges = FLAGS_storage_properties_on_edges, .enable_schema_metadata = FLAGS_storage_enable_schema_metadata, + .enable_label_index_auto_creation = FLAGS_storage_enable_automatic_label_index_creation, + .enable_edge_type_index_auto_creation = + FLAGS_storage_properties_on_edges ? FLAGS_storage_enable_automatic_edge_type_index_creation + : false, .delta_on_identical_property_update = FLAGS_storage_delta_on_identical_property_update}, .salient.storage_mode = memgraph::flags::ParseStorageMode()}; + if (db_config.salient.items.enable_edge_type_index_auto_creation && !db_config.salient.items.properties_on_edges) { + spdlog::warn( + "Automatic index creation on edge-types has been set but properties on edges are disabled. This will " + "implicitly disallow automatic edge-type index creation. If you wish to use automatic edge-type index " + "creation, enable properties on edges as well."); + } spdlog::info("config recover on startup {}, flags {} {}", db_config.durability.recover_on_startup, FLAGS_storage_recover_on_startup, FLAGS_data_recovery_on_startup); memgraph::utils::Scheduler jemalloc_purge_scheduler; diff --git a/src/storage/v2/config.hpp b/src/storage/v2/config.hpp index 419f29b85..bac77945d 100644 --- a/src/storage/v2/config.hpp +++ b/src/storage/v2/config.hpp @@ -37,6 +37,8 @@ struct SalientConfig { struct Items { bool properties_on_edges{true}; bool enable_schema_metadata{false}; + bool enable_label_index_auto_creation{false}; + bool enable_edge_type_index_auto_creation{false}; bool delta_on_identical_property_update{true}; friend bool operator==(const Items &lrh, const Items &rhs) = default; } items; @@ -45,13 +47,19 @@ struct SalientConfig { }; inline void to_json(nlohmann::json &data, SalientConfig::Items const &items) { - data = nlohmann::json{{"properties_on_edges", items.properties_on_edges}, - {"enable_schema_metadata", items.enable_schema_metadata}}; + data = nlohmann::json{ + {"properties_on_edges", items.properties_on_edges}, + {"enable_schema_metadata", items.enable_schema_metadata}, + {"enable_label_index_auto_creation", items.enable_label_index_auto_creation}, + {"enable_edge_type_index_auto_creation", items.enable_edge_type_index_auto_creation}, + }; } inline void from_json(const nlohmann::json &data, SalientConfig::Items &items) { data.at("properties_on_edges").get_to(items.properties_on_edges); data.at("enable_schema_metadata").get_to(items.enable_schema_metadata); + data.at("enable_label_index_auto_creation").get_to(items.enable_label_index_auto_creation); + data.at("enable_edge_type_index_auto_creation").get_to(items.enable_edge_type_index_auto_creation); } inline void to_json(nlohmann::json &data, SalientConfig const &config) {