From: Anton Khorev Date: Fri, 5 Apr 2024 09:21:08 +0000 (+0300) Subject: Add (creator_id, id) index to blocks table X-Git-Tag: live~605^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/b8cf4b59e5dab79dfd0fc75ef7d5afe90eebf7ae Add (creator_id, id) index to blocks table --- diff --git a/app/models/user_block.rb b/app/models/user_block.rb index 7af1f9bdc..4fe50d921 100644 --- a/app/models/user_block.rb +++ b/app/models/user_block.rb @@ -15,7 +15,8 @@ # # Indexes # -# index_user_blocks_on_user_id (user_id) +# index_user_blocks_on_creator_id_and_id (creator_id,id) +# index_user_blocks_on_user_id (user_id) # # Foreign Keys # diff --git a/db/migrate/20240405083825_add_creator_index_to_user_blocks.rb b/db/migrate/20240405083825_add_creator_index_to_user_blocks.rb new file mode 100644 index 000000000..542a1020d --- /dev/null +++ b/db/migrate/20240405083825_add_creator_index_to_user_blocks.rb @@ -0,0 +1,7 @@ +class AddCreatorIndexToUserBlocks < ActiveRecord::Migration[7.1] + disable_ddl_transaction! + + def change + add_index :user_blocks, [:creator_id, :id], :algorithm => :concurrently + end +end diff --git a/db/structure.sql b/db/structure.sql index 294fda4c8..829595e7c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2728,6 +2728,13 @@ CREATE INDEX index_reports_on_issue_id ON public.reports USING btree (issue_id); CREATE INDEX index_reports_on_user_id ON public.reports USING btree (user_id); +-- +-- Name: index_user_blocks_on_creator_id_and_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_user_blocks_on_creator_id_and_id ON public.user_blocks USING btree (creator_id, id); + + -- -- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: - -- @@ -3512,6 +3519,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('23'), ('22'), ('21'), +('20240405083825'), ('20240307181018'), ('20240307180830'), ('20240228205723'),