RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
perf(ingestion): add indexes for task user and status filters (#21379)
adws5fa79fa32d4c
diff --git a/internal/dao/database_test.go b/internal/dao/database_test.goindex 8a9bd67380..6cf67663f7 100644--- a/internal/dao/database_test.go+++ b/internal/dao/database_test.go@@ -105,6 +105,24 @@ func TestAutoMigrateRuntimeModelsCreatesGoRuntimeTables(t *testing.T) {}}+func TestAutoMigrateRuntimeModelsAddsIngestionTaskFilterIndexes(t *testing.T) {+ db := setupTaskTestDB(t)+ indexes := []string{"idx_ingestion_task_user_id", "idx_ingestion_task_status"}+ for _, name := range indexes {+ if err := db.Migrator().DropIndex(&entity.IngestionTask{}, name); err != nil {+ t.Fatalf("drop index %s: %v", name, err)+ }+ }+ if err := autoMigrateRuntimeModels(t.Context(), db); err != nil {+ t.Fatalf("migrate runtime models: %v", err)+ }+ for _, name := range indexes {+ if !db.Migrator().HasIndex(&entity.IngestionTask{}, name) {+ t.Errorf("missing task index %s after migration", name)+ }+ }+}+// TestMigrateIngestionTaskPipelineLogID covers the upgrade path AutoMigrate// cannot handle on MySQL: an existing ingestion_task created before// pipeline_log_id existed must gain the column, and running the migration againdiff --git a/internal/entity/ingestion_task.go b/internal/entity/ingestion_task.goindex 8ab377e1bc..80d30bf8af 100644--- a/internal/entity/ingestion_task.go+++ b/internal/entity/ingestion_task.go@@ -18,11 +18,11 @@ package entitytype IngestionTask struct {ID string `gorm:"column:id;primaryKey;size:32" json:"id"`- UserID string `gorm:"column:user_id;size:32;not null" json:"user_id"`+ UserID string `gorm:"column:user_id;size:32;not null;index:idx_ingestion_task_user_id" json:"user_id"`DocumentID string `gorm:"column:document_id;size:32;not null;uniqueIndex:idx_ingestion_task_document_id" json:"document_id"`DatasetID string `gorm:"column:dataset_id;size:32;not null;index:idx_ingestion_task_dataset_status,priority:1" json:"dataset_id"`Schema JSONMap `gorm:"column:schema;type:longtext" json:"schema"`- Status string `gorm:"column:status;size:32;not null;index:idx_ingestion_task_dataset_status,priority:2" json:"status"`+ Status string `gorm:"column:status;size:32;not null;index:idx_ingestion_task_dataset_status,priority:2;index:idx_ingestion_task_status" json:"status"`// ComponentTotal is the number of components in the task's DSL graph.// It is the authoritative denominator for progress percentage so the// frontend does not have to count DSL nodes itself. Written once the