Merge branch 'unused_indexes' into 'develop'

Remove unused indexes

See merge request pleroma/pleroma!3874
This commit is contained in:
lain 2023-06-11 19:48:23 +00:00
commit fdb5bec431
2 changed files with 74 additions and 0 deletions

1
changelog.d/3874.remove Normal file
View file

@ -0,0 +1 @@
Remove a few unused indexes.

View file

@ -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