perf(api): utilize the message_workflow_run_id_idx while querying messages (#32944)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
QuantumGhostandautofix-ci[bot] authored and GitHub committed 2026-03-04 14:11:14 +08:00
1 parent 84dca83ecd
commit e1e1f81bde
2 files changed
+172 -3

No files matched your search

@@ -321,7 +321,13 @@ def _resume_app_execution(payload: dict[str, Any]) -> None:
return
message = session.scalar(
select(Message).where(Message.workflow_run_id == workflow_run_id).order_by(Message.created_at.desc())
select(Message)
.where(
Message.conversation_id == conversation.id,
Message.workflow_run_id == workflow_run_id,
)
.order_by(Message.created_at.desc())
.limit(1)
)
if message is None:
logger.warning("Message not found for workflow run %s", workflow_run_id)