ai tags: replace tag_id index with (tag_id, score) index.
Index on (tag_id, score) instead of (tag_id) to allow tags to be filtered and sorted by confidence more efficiently. This index takes up about the same amount of space as an index on tag_id alone, so including the score in the index is essentially free.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
class AddTagIdAndScoreIndexToAITags < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_index :ai_tags, [:tag_id, :score], if_not_exists: true
|
||||||
|
remove_index :ai_tags, :tag_id
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -3149,10 +3149,10 @@ CREATE INDEX index_ai_tags_on_score ON public.ai_tags USING btree (score);
|
|||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_ai_tags_on_tag_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_ai_tags_on_tag_id_and_score; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
|
||||||
CREATE INDEX index_ai_tags_on_tag_id ON public.ai_tags USING btree (tag_id);
|
CREATE INDEX index_ai_tags_on_tag_id_and_score ON public.ai_tags USING btree (tag_id, score);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -5975,6 +5975,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||||||
('20220504235329'),
|
('20220504235329'),
|
||||||
('20220514175125'),
|
('20220514175125'),
|
||||||
('20220525214746'),
|
('20220525214746'),
|
||||||
('20220623052547');
|
('20220623052547'),
|
||||||
|
('20220627211714');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user