diff --git a/db/migrate/20241228202733_add_indices_suggested_by_pg_hero.rb b/db/migrate/20241228202733_add_indices_suggested_by_pg_hero.rb new file mode 100644 index 000000000..62a6470f5 --- /dev/null +++ b/db/migrate/20241228202733_add_indices_suggested_by_pg_hero.rb @@ -0,0 +1,17 @@ +class AddIndicesSuggestedByPgHero < ActiveRecord::Migration[8.0] + disable_ddl_transaction! + + def change + add_index :collected_pens, :user_id, algorithm: :concurrently + add_index :collected_pens, + :model, + using: "gist", + opclass: :gist_trgm_ops, + algorithm: :concurrently + add_index :collected_pens, + :brand, + using: "gist", + opclass: :gist_trgm_ops, + algorithm: :concurrently + end +end diff --git a/db/migrate/20241228204210_remove_indices_as_suggested_by_pg_hero.rb b/db/migrate/20241228204210_remove_indices_as_suggested_by_pg_hero.rb new file mode 100644 index 000000000..f5c239340 --- /dev/null +++ b/db/migrate/20241228204210_remove_indices_as_suggested_by_pg_hero.rb @@ -0,0 +1,17 @@ +class RemoveIndicesAsSuggestedByPgHero < ActiveRecord::Migration[8.0] + def change + remove_index :collected_inks, + name: "index_collected_inks_on_archived_on", + column: :archived_on + remove_index :gutentag_taggings, + name: + "index_gutentag_taggings_on_taggable_type_and_taggable_id", + column: %i[taggable_type taggable_id] + remove_index :leader_board_rows, + name: "index_leader_board_rows_on_type", + column: :type + remove_index :usage_records, + name: "index_usage_records_on_currently_inked_id", + column: :currently_inked_id + end +end diff --git a/db/structure.sql b/db/structure.sql index 80084397f..656b661b0 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -23,6 +23,20 @@ CREATE EXTENSION IF NOT EXISTS fuzzystrmatch WITH SCHEMA public; COMMENT ON EXTENSION fuzzystrmatch IS 'determine similarities and distance between strings'; +-- +-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: - +-- + +CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public; + + +-- +-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner: - +-- + +COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed'; + + -- -- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: - -- @@ -1335,13 +1349,6 @@ CREATE INDEX index_brand_clusters_on_description ON public.brand_clusters USING CREATE UNIQUE INDEX index_brand_clusters_on_name ON public.brand_clusters USING btree (name); --- --- Name: index_collected_inks_on_archived_on; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_collected_inks_on_archived_on ON public.collected_inks USING btree (archived_on); - - -- -- Name: index_collected_inks_on_archived_on_and_user_id; Type: INDEX; Schema: public; Owner: - -- @@ -1398,6 +1405,20 @@ CREATE INDEX index_collected_inks_on_simplified_ink_name ON public.collected_ink CREATE INDEX index_collected_inks_on_tsv ON public.collected_inks USING gin (tsv); +-- +-- Name: index_collected_pens_on_brand; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_collected_pens_on_brand ON public.collected_pens USING gist (brand public.gist_trgm_ops); + + +-- +-- Name: index_collected_pens_on_model; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_collected_pens_on_model ON public.collected_pens USING gist (model public.gist_trgm_ops); + + -- -- Name: index_collected_pens_on_pens_micro_cluster_id; Type: INDEX; Schema: public; Owner: - -- @@ -1405,6 +1426,13 @@ CREATE INDEX index_collected_inks_on_tsv ON public.collected_inks USING gin (tsv CREATE INDEX index_collected_pens_on_pens_micro_cluster_id ON public.collected_pens USING btree (pens_micro_cluster_id); +-- +-- Name: index_collected_pens_on_user_id; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX index_collected_pens_on_user_id ON public.collected_pens USING btree (user_id); + + -- -- Name: index_currently_inked_on_collected_ink_id; Type: INDEX; Schema: public; Owner: - -- @@ -1433,13 +1461,6 @@ CREATE INDEX index_currently_inked_on_user_id ON public.currently_inked USING bt CREATE INDEX index_gutentag_taggings_on_tag_id ON public.gutentag_taggings USING btree (tag_id); --- --- Name: index_gutentag_taggings_on_taggable_type_and_taggable_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_gutentag_taggings_on_taggable_type_and_taggable_id ON public.gutentag_taggings USING btree (taggable_type, taggable_id); - - -- -- Name: index_gutentag_tags_on_name; Type: INDEX; Schema: public; Owner: - -- @@ -1496,13 +1517,6 @@ CREATE INDEX index_ink_reviews_on_macro_cluster_id ON public.ink_reviews USING b CREATE UNIQUE INDEX index_ink_reviews_on_url_and_macro_cluster_id ON public.ink_reviews USING btree (url, macro_cluster_id); --- --- Name: index_leader_board_rows_on_type; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_leader_board_rows_on_type ON public.leader_board_rows USING btree (type); - - -- -- Name: index_leader_board_rows_on_type_and_user_id; Type: INDEX; Schema: public; Owner: - -- @@ -1636,13 +1650,6 @@ CREATE INDEX index_reading_statuses_on_blog_post_id ON public.reading_statuses U CREATE INDEX index_reading_statuses_on_user_id ON public.reading_statuses USING btree (user_id); --- --- Name: index_usage_records_on_currently_inked_id; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_usage_records_on_currently_inked_id ON public.usage_records USING btree (currently_inked_id); - - -- -- Name: index_usage_records_on_currently_inked_id_and_used_on; Type: INDEX; Schema: public; Owner: - -- @@ -1919,6 +1926,8 @@ ALTER TABLE ONLY public.collected_inks SET search_path TO "$user", public; INSERT INTO "schema_migrations" (version) VALUES +('20241228204210'), +('20241228202733'), ('20241211115823'), ('20241114144808'), ('20240916060008'), diff --git a/docker-compose.yml b/docker-compose.yml index ced82d03f..15cb3735a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,6 +7,7 @@ x-rails: &rails context: . target: dev environment: + NEW_RELIC_LOG: stdout NODE_ENV: development PORT: 80 POSTGRES_PASSWORD: fpc