summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete <pete@debu.gs>2022-05-06 18:35:09 -0700
committerPete <pete@debu.gs>2022-05-06 18:48:08 -0700
commitaa51fd068bb8f02660ebb653d240b09eec502957 (patch)
treea54a403b92156a28d8655f52f5f6021d94a0d3c3
parentf9943b2065598d2154b400170d051656a0107518 (diff)
Add index hotspots
squash
-rw-r--r--priv/repo/migrations/20220506175506_add_index_hotspots.exs17
1 files changed, 17 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220506175506_add_index_hotspots.exs b/priv/repo/migrations/20220506175506_add_index_hotspots.exs
new file mode 100644
index 000000000..e1f59bbac
--- /dev/null
+++ b/priv/repo/migrations/20220506175506_add_index_hotspots.exs
@@ -0,0 +1,17 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Repo.Migrations.AddIndexHotspots do
+ use Ecto.Migration
+
+ def change do
+ # Stop inserts into activities from doing a full-table scan of users:
+ create_if_not_exists(index(:users, [:ap_id, "COALESCE(follower_address, '')"]))
+
+ # Change two indexes and a filter recheck into one index scan:
+ create_if_not_exists(index(:following_relationships, [:follower_id, :state]))
+
+ create_if_not_exists(index(:notifications, [:user_id, :seen]))
+ end
+end