Skip to content

Commit

Permalink
Index SearchableContents using btree_gin
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorvsk committed Nov 5, 2023
1 parent 1a8e6da commit a035a7d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions db/migrate/20231105000145_add_btree_gin_extension.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddBtreeGinExtension < ActiveRecord::Migration[7.0]
def change
enable_extension "btree_gin"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class IndexBtreeGinOnSearchableContents < ActiveRecord::Migration[7.0]
def change
remove_index :searchable_contents, :tsv_content, using: :gin
add_index :searchable_contents, [:tsv_content, :event_id], using: :gin
end
end
22 changes: 19 additions & 3 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;

--
-- Name: btree_gin; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS btree_gin WITH SCHEMA public;


--
-- Name: EXTENSION btree_gin; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION btree_gin IS 'support for indexing common datatypes in GIN';


--
-- Name: citext; Type: EXTENSION; Schema: -; Owner: -
--
Expand Down Expand Up @@ -732,10 +746,10 @@ CREATE UNIQUE INDEX index_searchable_contents_on_event_id ON public.searchable_c


--
-- Name: index_searchable_contents_on_tsv_content; Type: INDEX; Schema: public; Owner: -
-- Name: index_searchable_contents_on_tsv_content_and_event_id; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX index_searchable_contents_on_tsv_content ON public.searchable_contents USING gin (tsv_content);
CREATE INDEX index_searchable_contents_on_tsv_content_and_event_id ON public.searchable_contents USING gin (tsv_content, event_id);


--
Expand Down Expand Up @@ -962,6 +976,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20230826153633'),
('20230827140714'),
('20230827170307'),
('20231025122455');
('20231025122455'),
('20231105000145'),
('20231105000543');


0 comments on commit a035a7d

Please sign in to comment.