Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit cc77e73

Browse files
authored
PERF: Create index ON ai_topics_embeddings(topic_id, model_id) (#1513)
This index helps to speed up queries that joins the `topics` table against the `ai_topics_embeddings` table on the `topic_id` column. There are a number of queries which filters on `ai_topics_embeddings.model_id` so we are including that in the index as well.
1 parent 1d88ca4 commit cc77e73

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
class AddIndexToAiTopicsEmbeddings < ActiveRecord::Migration[7.2]
4+
def up
5+
add_index :ai_topics_embeddings, %i[topic_id model_id]
6+
end
7+
8+
def down
9+
raise ActiveRecord::IrreversibleMigration
10+
end
11+
end

0 commit comments

Comments
 (0)