commit: fdb5bec431ad815263bae542324257a8ca29d81e
parent d65a8bcd2d74f5a87c889e754b6918747bb889fc
Author: lain <lain@soykaf.club>
Date: Sun, 11 Jun 2023 19:48:23 +0000
Merge branch 'unused_indexes' into 'develop'
Remove unused indexes
See merge request pleroma/pleroma!3874
Diffstat:
2 files changed, 74 insertions(+), 0 deletions(-)
diff --git a/changelog.d/3874.remove b/changelog.d/3874.remove
@@ -0,0 +1 @@
+Remove a few unused indexes.
diff --git a/priv/repo/migrations/20230422154018_drop_unused_indexes.exs b/priv/repo/migrations/20230422154018_drop_unused_indexes.exs
@@ -0,0 +1,73 @@
+defmodule Pleroma.Repo.Migrations.DropUnusedIndexes do
+ use Ecto.Migration
+
+ @disable_ddl_transaction true
+ @disable_migration_lock true
+
+ def up do
+ drop_if_exists(
+ index(:activities, ["(data->>'actor')", "inserted_at desc"], name: :activities_actor_index)
+ )
+
+ drop_if_exists(index(:activities, ["(data->'to')"], name: :activities_to_index))
+
+ drop_if_exists(index(:activities, ["(data->'cc')"], name: :activities_cc_index))
+
+ drop_if_exists(index(:activities, ["(split_part(actor, '/', 3))"], name: :activities_hosts))
+
+ drop_if_exists(
+ index(:activities, ["(data->'object'->>'inReplyTo')"], name: :activities_in_reply_to)
+ )
+
+ drop_if_exists(
+ index(:activities, ["((data #> '{\"object\",\"likes\"}'))"], name: :activities_likes)
+ )
+ end
+
+ def down do
+ create_if_not_exists(
+ index(:activities, ["(data->>'actor')", "inserted_at desc"],
+ name: :activities_actor_index,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:activities, ["(data->'to')"],
+ name: :activities_to_index,
+ using: :gin,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:activities, ["(data->'cc')"],
+ name: :activities_cc_index,
+ using: :gin,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:activities, ["(split_part(actor, '/', 3))"],
+ name: :activities_hosts,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:activities, ["(data->'object'->>'inReplyTo')"],
+ name: :activities_in_reply_to,
+ concurrently: true
+ )
+ )
+
+ create_if_not_exists(
+ index(:activities, ["((data #> '{\"object\",\"likes\"}'))"],
+ name: :activities_likes,
+ using: :gin,
+ concurrently: true
+ )
+ )
+ end
+end