Add an index on object likes
authorrinpatch <rinpatch@sdf.org>
Fri, 23 Aug 2019 00:17:20 +0000 (03:17 +0300)
committerrinpatch <rinpatch@sdf.org>
Fri, 23 Aug 2019 00:17:20 +0000 (03:17 +0300)
In !1538 favorites timeline was switched to use the joined object, but
no idex on likes in the joined object was added.

CHANGELOG.md
priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs [new file with mode: 0644]

index 7b0f4f40e5b2d96b06de201f74ebbc5223ca8dda..880fba58acf87c2c4a58f41efdbf12d9d14344b7 100644 (file)
@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 ### Fixed
 - Not being able to pin unlisted posts
 - Objects being re-embedded to activities after being updated (e.g faved/reposted). Running 'mix pleroma.database prune_objects' again is advised.
+- Favorites timeline doing database-intensive queries
 - Metadata rendering errors resulting in the entire page being inaccessible
 - `federation_incoming_replies_max_depth` option being ignored in certain cases
 - Federation/MediaProxy not working with instances that have wrong certificate order
diff --git a/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs b/priv/repo/migrations/20190823000549_add_likes_index_to_objects.exs
new file mode 100644 (file)
index 0000000..13f3d6e
--- /dev/null
@@ -0,0 +1,7 @@
+defmodule Pleroma.Repo.Migrations.AddLikesIndexToObjects do
+  use Ecto.Migration
+
+  def change do
+    create_if_not_exists index(:objects, ["(data->'likes')"], using: :gin, name: :objects_likes)
+  end
+end