From fa418271396eb61b74930be36d06082cdf2172d7 Mon Sep 17 00:00:00 2001 From: Ankit Nayan Date: Thu, 15 Aug 2024 19:11:03 +0530 Subject: [PATCH 1/2] chore: add indices for attributes --- .../migrations/000030_add_attributes_indices.down.sql | 8 ++++++++ .../migrations/000030_add_attributes_indices.up.sql | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.down.sql create mode 100644 migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.up.sql diff --git a/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.down.sql b/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.down.sql new file mode 100644 index 00000000..2a60ab8c --- /dev/null +++ b/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.down.sql @@ -0,0 +1,8 @@ +ALTER TABLE signoz_traces.signoz_index_v2 ON CLUSTER {{.SIGNOZ_CLUSTER}} + DROP INDEX IF EXISTS idx_stringTagMapKeys, + DROP INDEX IF EXISTS idx_stringTagMapValues, + + DROP INDEX IF EXISTS idx_numberTagMapKeys, + DROP INDEX IF EXISTS idx_numberTagMapValues, + + DROP INDEX IF EXISTS idx_boolTagMapKeys; \ No newline at end of file diff --git a/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.up.sql b/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.up.sql new file mode 100644 index 00000000..63be150e --- /dev/null +++ b/migrationmanager/migrators/traces/migrations/000030_add_attributes_indices.up.sql @@ -0,0 +1,8 @@ +ALTER TABLE signoz_traces.signoz_index_v2 ON CLUSTER {{.SIGNOZ_CLUSTER}} + ADD INDEX IF NOT EXISTS idx_stringTagMapKeys mapKeys(stringTagMap) TYPE tokenbf_v1(1024, 2, 0) GRANULARITY 1, + ADD INDEX IF NOT EXISTS idx_stringTagMapValues mapValues(stringTagMap) TYPE ngrambf_v1(4, 5000, 2, 0) GRANULARITY 1, + + ADD INDEX IF NOT EXISTS idx_numberTagMapValues mapKeys(numberTagMap) TYPE tokenbf_v1(1024, 2, 0) GRANULARITY 1, + ADD INDEX IF NOT EXISTS idx_numberTagMapValues mapValues(numberTagMap) TYPE bloom_filter(0.01) GRANULARITY 1, + + ADD INDEX IF NOT EXISTS idx_boolTagMapKeys mapKeys(boolTagMap) TYPE tokenbf_v1(1024, 2, 0) GRANULARITY 1; From 22d9183f4be91ec31cadd46f0932064eb7343a31 Mon Sep 17 00:00:00 2001 From: Ankit Nayan Date: Sun, 8 Sep 2024 19:47:25 +0530 Subject: [PATCH 2/2] Chore/change resourcemap index (#365) change the type of index for resource attributes from `bloom_filter` to `tokenbf_v1` for keys and `ngrambf_v1` for values. This is tested and implemented in logs already. --- .../migrations/000031_change_resource_index.down.sql | 8 ++++++++ .../traces/migrations/000031_change_resource_index.up.sql | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 migrationmanager/migrators/traces/migrations/000031_change_resource_index.down.sql create mode 100644 migrationmanager/migrators/traces/migrations/000031_change_resource_index.up.sql diff --git a/migrationmanager/migrators/traces/migrations/000031_change_resource_index.down.sql b/migrationmanager/migrators/traces/migrations/000031_change_resource_index.down.sql new file mode 100644 index 00000000..2200f903 --- /dev/null +++ b/migrationmanager/migrators/traces/migrations/000031_change_resource_index.down.sql @@ -0,0 +1,8 @@ +ALTER TABLE signoz_traces.signoz_index_v2 ON CLUSTER {{.SIGNOZ_CLUSTER}} + DROP INDEX IF EXISTS idx_resourceTagMapKeys, + DROP INDEX IF EXISTS idx_resourceTagMapValues, + + ADD INDEX IF NOT EXISTS idx_resourceTagsMapKeys mapKeys(resourceTagsMap) TYPE bloom_filter(0.01) GRANULARITY 64, + ADD INDEX IF NOT EXISTS idx_resourceTagsMapValues mapValues(resourceTagsMap) TYPE bloom_filter(0.01) GRANULARITY 64; + + diff --git a/migrationmanager/migrators/traces/migrations/000031_change_resource_index.up.sql b/migrationmanager/migrators/traces/migrations/000031_change_resource_index.up.sql new file mode 100644 index 00000000..c6fac2b3 --- /dev/null +++ b/migrationmanager/migrators/traces/migrations/000031_change_resource_index.up.sql @@ -0,0 +1,3 @@ +ALTER TABLE signoz_traces.signoz_index_v2 ON CLUSTER {{.SIGNOZ_CLUSTER}} + ADD INDEX IF NOT EXISTS idx_resourceTagMapKeys mapKeys(resourceTagsMap) TYPE tokenbf_v1(1024, 2, 0) GRANULARITY 1, + ADD INDEX IF NOT EXISTS idx_resourceTagMapValues mapValues(resourceTagsMap) TYPE ngrambf_v1(4, 5000, 2, 0) GRANULARITY 1;