From a589e8c8ed6462af5b400e4ffa2b6205efaa0e22 Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Fri, 29 Mar 2024 16:10:33 +0300 Subject: [PATCH 1/4] Remove unused indexes Signed-off-by: sashayakovtseva --- .../ydb/migrations/zz_migration.0001_initial_schema.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go index c19ae4dbb2..321bdf4823 100644 --- a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go +++ b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go @@ -89,10 +89,6 @@ CREATE TABLE relation_tuple ( deleted_at_unix_nano Int64, PRIMARY KEY (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, created_at_unix_nano), INDEX uq_relation_tuple_living GLOBAL SYNC ON (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, deleted_at_unix_nano), - INDEX ix_relation_tuple_by_subject GLOBAL SYNC ON (userset_object_id, userset_namespace, userset_relation, namespace, relation), - INDEX ix_relation_tuple_by_subject_relation GLOBAL SYNC ON (userset_namespace, userset_relation, namespace, relation), - INDEX ix_relation_tuple_alive_by_resource_rel_subject_covering GLOBAL SYNC ON (namespace, relation, userset_namespace) COVER (caveat_name, caveat_context), - INDEX ix_gc_index GLOBAL SYNC ON (deleted_at_unix_nano) ) WITH ( AUTO_PARTITIONING_BY_SIZE = DISABLED, From 44d948de8d2d98d3fac45af9ccedf81fd170cafc Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Fri, 29 Mar 2024 16:14:56 +0300 Subject: [PATCH 2/4] Update table parameters Signed-off-by: sashayakovtseva --- .../zz_migration.0001_initial_schema.go | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go index 321bdf4823..22fed50fef 100644 --- a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go +++ b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go @@ -50,9 +50,12 @@ CREATE TABLE namespace_config ( INDEX uq_namespace_living GLOBAL SYNC ON (deleted_at_unix_nano, namespace) COVER (serialized_config) ) WITH ( - AUTO_PARTITIONING_BY_SIZE = DISABLED, + AUTO_PARTITIONING_BY_SIZE = ENABLED, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, AUTO_PARTITIONING_BY_LOAD = ENABLED, - AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 3 + AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, + AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024, + KEY_BLOOM_FILTER = ENABLED );` // ideally PK should be (name, deleted_at_unix_nano), but since deleted_at_unix_nano is @@ -69,9 +72,12 @@ CREATE TABLE caveat ( INDEX uq_caveat_living GLOBAL SYNC ON (deleted_at_unix_nano, name) COVER (definition) ) WITH ( - AUTO_PARTITIONING_BY_SIZE = DISABLED, + AUTO_PARTITIONING_BY_SIZE = ENABLED, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, AUTO_PARTITIONING_BY_LOAD = ENABLED, - AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 3 + AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, + AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024, + KEY_BLOOM_FILTER = ENABLED );` // todo use correct indexes. @@ -91,9 +97,12 @@ CREATE TABLE relation_tuple ( INDEX uq_relation_tuple_living GLOBAL SYNC ON (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, deleted_at_unix_nano), ) WITH ( - AUTO_PARTITIONING_BY_SIZE = DISABLED, + AUTO_PARTITIONING_BY_SIZE = ENABLED, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, AUTO_PARTITIONING_BY_LOAD = ENABLED, - AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 3 + AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, + AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024, + KEY_BLOOM_FILTER = ENABLED );` createNamespaceConfigChangefeed = ` From c7e838e2070267d8831fefbb01faa66cefc768b6 Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Fri, 29 Mar 2024 16:17:47 +0300 Subject: [PATCH 3/4] Fix typo Signed-off-by: sashayakovtseva --- .../ydb/migrations/zz_migration.0001_initial_schema.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go index 22fed50fef..55dffb8b43 100644 --- a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go +++ b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go @@ -94,7 +94,7 @@ CREATE TABLE relation_tuple ( created_at_unix_nano Int64 NOT NULL, deleted_at_unix_nano Int64, PRIMARY KEY (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, created_at_unix_nano), - INDEX uq_relation_tuple_living GLOBAL SYNC ON (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, deleted_at_unix_nano), + INDEX uq_relation_tuple_living GLOBAL SYNC ON (namespace, object_id, relation, userset_namespace, userset_object_id, userset_relation, deleted_at_unix_nano) ) WITH ( AUTO_PARTITIONING_BY_SIZE = ENABLED, From 7a7a92f8523cc89c63577d100733a71fc61433ba Mon Sep 17 00:00:00 2001 From: sashayakovtseva Date: Fri, 29 Mar 2024 16:43:22 +0300 Subject: [PATCH 4/4] Update part size Signed-off-by: sashayakovtseva --- .../ydb/migrations/zz_migration.0001_initial_schema.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go index 55dffb8b43..4795438883 100644 --- a/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go +++ b/internal/datastore/ydb/migrations/zz_migration.0001_initial_schema.go @@ -51,7 +51,7 @@ CREATE TABLE namespace_config ( ) WITH ( AUTO_PARTITIONING_BY_SIZE = ENABLED, - AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 1024, AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024, @@ -73,7 +73,7 @@ CREATE TABLE caveat ( ) WITH ( AUTO_PARTITIONING_BY_SIZE = ENABLED, - AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 1024, AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024, @@ -98,7 +98,7 @@ CREATE TABLE relation_tuple ( ) WITH ( AUTO_PARTITIONING_BY_SIZE = ENABLED, - AUTO_PARTITIONING_PARTITION_SIZE_MB = 2048, + AUTO_PARTITIONING_PARTITION_SIZE_MB = 1024, AUTO_PARTITIONING_BY_LOAD = ENABLED, AUTO_PARTITIONING_MIN_PARTITIONS_COUNT = 4, AUTO_PARTITIONING_MAX_PARTITIONS_COUNT = 1024,