From 6a3a0270a26e6e1abdeae99f0882f82f8f76d173 Mon Sep 17 00:00:00 2001 From: Pete Date: Fri, 6 May 2022 18:35:09 -0700 Subject: [PATCH] Add index hotspots squash --- .../20220506175506_add_index_hotspots.exs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 priv/repo/migrations/20220506175506_add_index_hotspots.exs 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..352ff3c08 --- /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 +# 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