fix SQL slow query (#2043)

Co-authored-by: jyong <jyong@dify.ai>
This commit is contained in:
Jyong 2024-01-16 00:59:28 +08:00 committed by GitHub
parent 83105d0d8f
commit add33cb5e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -94,6 +94,7 @@ class DatasetMultiRetrieverTool(BaseTool):
document_context_list = []
index_node_ids = [document.metadata['doc_id'] for document in all_documents]
segments = DocumentSegment.query.filter(
DocumentSegment.dataset_id.in_(self.dataset_ids),
DocumentSegment.completed_at.isnot(None),
DocumentSegment.status == 'completed',
DocumentSegment.enabled == True,