Remove unused indexes
These indexes were always listed as unused and several grow quite large. The most significant impact is the activities_visibility_index which takes many hours to rebuild when restoring the server from backup even on fast hardware.
This commit is contained in:
parent
3867b52aef
commit
d91a823836
|
@ -0,0 +1,88 @@
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
|
||||||
|
drop_if_exists(
|
||||||
|
index(:activities, ["activity_visibility(actor, recipients, data)", "id DESC NULLS LAST"],
|
||||||
|
name: :activities_visibility_index,
|
||||||
|
where: "data->>'type' = 'Create'"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
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
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
create_if_not_exists(
|
||||||
|
index(:activities, ["activity_visibility(actor, recipients, data)", "id DESC NULLS LAST"],
|
||||||
|
name: :activities_visibility_index,
|
||||||
|
where: "data->>'type' = 'Create'",
|
||||||
|
concurrently: true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue