summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs')
-rw-r--r--priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs40
1 files changed, 40 insertions, 0 deletions
diff --git a/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs b/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs
new file mode 100644
index 000000000..3d112d172
--- /dev/null
+++ b/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs
@@ -0,0 +1,40 @@
+defmodule Pleroma.Repo.Migrations.AddObjectConcurrentIndexes do
+ use Ecto.Migration
+ @disable_migration_lock true
+ @disable_ddl_transaction true
+
+ def change do
+ create_if_not_exists(index(:objects, [:actor, "id DESC NULLS LAST"], concurrently: true))
+
+ create_if_not_exists(
+ index(:objects, ["(data->>'type')", "(data->>'context')"],
+ name: :objects_context_index,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:objects, ["(split_part(actor, '/', 3))"],
+ concurrently: true,
+ name: :objects_hosts
+ )
+ )
+
+ create_if_not_exists(index(:objects, ["id desc nulls last", "local"], concurrently: true))
+
+ create_if_not_exists(
+ index(:objects, ["activity_visibility(actor, recipients, data)", "id DESC NULLS LAST"],
+ name: :objects_visibility_index,
+ concurrently: true,
+ where: "data->>'type' = 'Create'"
+ )
+ )
+
+ create_if_not_exists(
+ index(:objects, ["(coalesce(data->'object'->>'id', data->>'object'))"],
+ name: :objects_create_objects_index,
+ concurrently: true
+ )
+ )
+ end
+end