]> git.openstreetmap.org Git - rails.git/commitdiff
Add indexes on user+id to changeset and diary comments
authorTom Hughes <tom@compton.nu>
Tue, 21 Jan 2025 19:21:17 +0000 (19:21 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 21 Jan 2025 20:15:56 +0000 (20:15 +0000)
app/models/changeset_comment.rb
app/models/diary_comment.rb
db/migrate/20250121191749_add_user_comment_indexes.rb [new file with mode: 0644]
db/structure.sql

index 22d158e82ce5a78591a9fb7ba7aeb774c85565ca..d825c9ed58d4fe1f3ef99937278238848585a654 100644 (file)
@@ -12,6 +12,7 @@
 # Indexes
 #
 #  index_changeset_comments_on_author_id_and_created_at     (author_id,created_at)
 # Indexes
 #
 #  index_changeset_comments_on_author_id_and_created_at     (author_id,created_at)
+#  index_changeset_comments_on_author_id_and_id             (author_id,id)
 #  index_changeset_comments_on_changeset_id_and_created_at  (changeset_id,created_at)
 #  index_changeset_comments_on_created_at                   (created_at)
 #
 #  index_changeset_comments_on_changeset_id_and_created_at  (changeset_id,created_at)
 #  index_changeset_comments_on_created_at                   (created_at)
 #
index a88c69f12ee3b3d8db208fa6405569e7dee5af15..ad23c9f65f3b6435814a3e6484ab1e7b41cc7b6b 100644 (file)
@@ -15,6 +15,7 @@
 #
 #  diary_comment_user_id_created_at_index  (user_id,created_at)
 #  diary_comments_entry_id_idx             (diary_entry_id,id) UNIQUE
 #
 #  diary_comment_user_id_created_at_index  (user_id,created_at)
 #  diary_comments_entry_id_idx             (diary_entry_id,id) UNIQUE
+#  index_diary_comments_on_user_id_and_id  (user_id,id)
 #
 # Foreign Keys
 #
 #
 # Foreign Keys
 #
diff --git a/db/migrate/20250121191749_add_user_comment_indexes.rb b/db/migrate/20250121191749_add_user_comment_indexes.rb
new file mode 100644 (file)
index 0000000..10af4e4
--- /dev/null
@@ -0,0 +1,8 @@
+class AddUserCommentIndexes < ActiveRecord::Migration[7.2]
+  disable_ddl_transaction!
+
+  def change
+    add_index :changeset_comments, [:author_id, :id], :algorithm => :concurrently
+    add_index :diary_comments, [:user_id, :id], :algorithm => :concurrently
+  end
+end
index 04b0dc17f13128dc12d1d7982a141243a1fe16e2..9093c47fe72c5c075e58bb5ff6659f54ec8e974b 100644 (file)
@@ -2400,6 +2400,13 @@ CREATE UNIQUE INDEX index_active_storage_variant_records_uniqueness ON public.ac
 CREATE INDEX index_changeset_comments_on_author_id_and_created_at ON public.changeset_comments USING btree (author_id, created_at);
 
 
 CREATE INDEX index_changeset_comments_on_author_id_and_created_at ON public.changeset_comments USING btree (author_id, created_at);
 
 
+--
+-- Name: index_changeset_comments_on_author_id_and_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_changeset_comments_on_author_id_and_id ON public.changeset_comments USING btree (author_id, id);
+
+
 --
 -- Name: index_changeset_comments_on_changeset_id_and_created_at; Type: INDEX; Schema: public; Owner: -
 --
 --
 -- Name: index_changeset_comments_on_changeset_id_and_created_at; Type: INDEX; Schema: public; Owner: -
 --
@@ -2435,6 +2442,13 @@ CREATE INDEX index_changesets_subscribers_on_changeset_id ON public.changesets_s
 CREATE UNIQUE INDEX index_changesets_subscribers_on_subscriber_id_and_changeset_id ON public.changesets_subscribers USING btree (subscriber_id, changeset_id);
 
 
 CREATE UNIQUE INDEX index_changesets_subscribers_on_subscriber_id_and_changeset_id ON public.changesets_subscribers USING btree (subscriber_id, changeset_id);
 
 
+--
+-- Name: index_diary_comments_on_user_id_and_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_diary_comments_on_user_id_and_id ON public.diary_comments USING btree (user_id, id);
+
+
 --
 -- Name: index_diary_entry_subscriptions_on_diary_entry_id; Type: INDEX; Schema: public; Owner: -
 --
 --
 -- Name: index_diary_entry_subscriptions_on_diary_entry_id; Type: INDEX; Schema: public; Owner: -
 --
@@ -3408,6 +3422,7 @@ INSERT INTO "schema_migrations" (version) VALUES
 ('23'),
 ('22'),
 ('21'),
 ('23'),
 ('22'),
 ('21'),
+('20250121191749'),
 ('20250105154621'),
 ('20250104140952'),
 ('20241023004427'),
 ('20250105154621'),
 ('20250104140952'),
 ('20241023004427'),