From f55aa85c681f9276d6daa00d97a7fe6a0ce9ed25 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 18 Sep 2022 23:31:30 -0500 Subject: [PATCH] db: add category and description indexes on mod_actions table. --- ...220919041622_add_indexes_to_mod_actions.rb | 7 ++++++ db/structure.sql | 24 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20220919041622_add_indexes_to_mod_actions.rb diff --git a/db/migrate/20220919041622_add_indexes_to_mod_actions.rb b/db/migrate/20220919041622_add_indexes_to_mod_actions.rb new file mode 100644 index 000000000..dcd045e5b --- /dev/null +++ b/db/migrate/20220919041622_add_indexes_to_mod_actions.rb @@ -0,0 +1,7 @@ +class AddIndexesToModActions < ActiveRecord::Migration[7.0] + def change + add_index :mod_actions, :category + add_index :mod_actions, :description, using: :gin, opclass: :gin_trgm_ops + add_index :mod_actions, "to_tsvector('pg_catalog.english', description)", using: :gin + end +end diff --git a/db/structure.sql b/db/structure.sql index 8a4c4d918..584b33da1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4332,6 +4332,13 @@ CREATE UNIQUE INDEX index_media_metadata_on_media_asset_id ON public.media_metad CREATE INDEX index_media_metadata_on_metadata ON public.media_metadata USING gin (metadata); +-- +-- Name: index_mod_actions_on_category; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mod_actions_on_category ON public.mod_actions USING btree (category); + + -- -- Name: index_mod_actions_on_created_at; Type: INDEX; Schema: public; Owner: - -- @@ -4353,6 +4360,20 @@ CREATE INDEX index_mod_actions_on_creator_id ON public.mod_actions USING btree ( CREATE INDEX index_mod_actions_on_creator_id_and_created_at ON public.mod_actions USING btree (creator_id, created_at); +-- +-- Name: index_mod_actions_on_description; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mod_actions_on_description ON public.mod_actions USING gin (description public.gin_trgm_ops); + + +-- +-- Name: index_mod_actions_on_to_tsvector_pg_catalog_english_description; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_mod_actions_on_to_tsvector_pg_catalog_english_description ON public.mod_actions USING gin (to_tsvector('english'::regconfig, description)); + + -- -- Name: index_moderation_reports_on_created_at; Type: INDEX; Schema: public; Owner: - -- @@ -6694,6 +6715,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220913191300'), ('20220913191309'), ('20220917204044'), -('20220918031429'); +('20220918031429'), +('20220919041622');