diff --git a/db/migrate/20180916002448_add_trigram_index_to_artist_urls.rb b/db/migrate/20180916002448_add_trigram_index_to_artist_urls.rb new file mode 100644 index 000000000..dd511a7b8 --- /dev/null +++ b/db/migrate/20180916002448_add_trigram_index_to_artist_urls.rb @@ -0,0 +1,12 @@ +class AddTrigramIndexToArtistUrls < ActiveRecord::Migration[5.2] + def change + change_table :artist_urls do |t| + t.remove_index column: :url, name: :index_artist_urls_on_url + t.remove_index column: :url, name: :index_artist_urls_on_url_pattern, opclass: :text_pattern_ops + t.remove_index column: :normalized_url, name: :index_artist_urls_on_normalized_url + + t.index :url, name: :index_artist_urls_on_url_trgm, using: :gin, opclass: :gin_trgm_ops + t.index :normalized_url, name: :index_artist_urls_on_normalized_url_trgm, using: :gin, opclass: :gin_trgm_ops + end + end +end diff --git a/db/structure.sql b/db/structure.sql index 243ae4d47..650beb267 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4944,13 +4944,6 @@ CREATE INDEX index_artist_commentary_versions_on_updater_ip_addr ON public.artis CREATE INDEX index_artist_urls_on_artist_id ON public.artist_urls USING btree (artist_id); --- --- Name: index_artist_urls_on_normalized_url; Type: INDEX; Schema: public; Owner: - --- - -CREATE INDEX index_artist_urls_on_normalized_url ON public.artist_urls USING btree (normalized_url); - - -- -- Name: index_artist_urls_on_normalized_url_pattern; Type: INDEX; Schema: public; Owner: - -- @@ -4959,17 +4952,17 @@ CREATE INDEX index_artist_urls_on_normalized_url_pattern ON public.artist_urls U -- --- Name: index_artist_urls_on_url; Type: INDEX; Schema: public; Owner: - +-- Name: index_artist_urls_on_normalized_url_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_url ON public.artist_urls USING btree (url); +CREATE INDEX index_artist_urls_on_normalized_url_trgm ON public.artist_urls USING gin (normalized_url public.gin_trgm_ops); -- --- Name: index_artist_urls_on_url_pattern; Type: INDEX; Schema: public; Owner: - +-- Name: index_artist_urls_on_url_trgm; Type: INDEX; Schema: public; Owner: - -- -CREATE INDEX index_artist_urls_on_url_pattern ON public.artist_urls USING btree (url text_pattern_ops); +CREATE INDEX index_artist_urls_on_url_trgm ON public.artist_urls USING gin (url public.gin_trgm_ops); -- @@ -7532,6 +7525,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('20180518175154'), ('20180804203201'), ('20180816230604'), -('20180912185624'); +('20180912185624'), +('20180913184128'), +('20180916002448');