diff --git a/internal/persistence/sql/migrations/sql/20220512151000000000_indices.down.sql b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.down.sql new file mode 100644 index 000000000..15e41a92a --- /dev/null +++ b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.down.sql @@ -0,0 +1,2 @@ +DROP INDEX keto_relation_tuples_reverse_subject_ids_idx; +DROP INDEX keto_relation_tuples_reverse_subject_sets_idx; diff --git a/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.down.sql b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.down.sql new file mode 100644 index 000000000..3ca89e77c --- /dev/null +++ b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.down.sql @@ -0,0 +1 @@ +DROP INDEX keto_relation_tuples_reverse_subject_idx; diff --git a/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.up.sql b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.up.sql new file mode 100644 index 000000000..9f3242f8b --- /dev/null +++ b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.mysql.up.sql @@ -0,0 +1,8 @@ +CREATE INDEX keto_relation_tuples_reverse_subject_idx ON keto_relation_tuples (nid, + subject_id, + subject_set_namespace_id, + subject_set_object, + subject_set_relation, + relation, + namespace_id, + ); diff --git a/internal/persistence/sql/migrations/sql/20220512151000000000_indices.up.sql b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.up.sql new file mode 100644 index 000000000..3d8871f06 --- /dev/null +++ b/internal/persistence/sql/migrations/sql/20220512151000000000_indices.up.sql @@ -0,0 +1,13 @@ +CREATE INDEX keto_relation_tuples_reverse_subject_ids_idx ON keto_relation_tuples (nid, + subject_id, + relation, + namespace_id, + ) WHERE subject_set_namespace_id IS NULL AND subject_set_object IS NULL AND subject_set_relation IS NULL; + +CREATE INDEX keto_relation_tuples_reverse_subject_sets_idx ON keto_relation_tuples (nid, + subject_set_namespace_id, + subject_set_object, + subject_set_relation, + relation, + namespace_id, + ) WHERE subject_id IS NULL;