[PR #31999] perf(api): Optimize the response time of AppListApi endpoint #33501

Closed
opened 2026-02-21 20:53:24 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/31999

State: closed
Merged: Yes


Summary

Query workflow with current_tenant_id to ensure the index workflow_version_idx can be fully utilized.

Closes #31998

Screenshots

image

Executed SQL:

2026-02-05 10:11:51,221 INFO sqlalchemy.engine.Engine SELECT workflows.id, workflows.tenant_id, workflows.app_id, workflows.type, workflows.version, workflows.marked_name, workflows.marked_comment, workflows.graph, workflows.features, workflows.created_by, workflows.created_at, workflows.updated_by, workflows.updated_at, workflows.environment_variables, workflows.conversation_variables, workflows.rag_pipeline_variables 
FROM workflows 
WHERE workflows.version = %(version_1)s AND workflows.app_id IN (%(app_id_1_1)s::UUID, %(app_id_1_2)s::UUID, %(app_id_1_3)s::UUID, %(app_id_1_4)s::UUID, %(app_id_1_5)s::UUID, %(app_id_1_6)s::UUID, %(app_id_1_7)s::UUID, %(app_id_1_8)s::UUID, %(app_id_1_9)s::UUID, %(app_id_1_10)s::UUID, %(app_id_1_11)s::UUID, %(app_id_1_12)s::UUID, %(app_id_1_13)s::UUID, %(app_id_1_14)s::UUID, %(app_id_1_15)s::UUID, %(app_id_1_16)s::UUID, %(app_id_1_17)s::UUID, %(app_id_1_18)s::UUID, %(app_id_1_19)s::UUID, %(app_id_1_20)s::UUID, %(app_id_1_21)s::UUID, %(app_id_1_22)s::UUID, %(app_id_1_23)s::UUID, %(app_id_1_24)s::UUID, %(app_id_1_25)s::UUID, %(app_id_1_26)s::UUID, %(app_id_1_27)s::UUID) AND workflows.tenant_id = %(tenant_id_1)s::UUID

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/31999 **State:** closed **Merged:** Yes --- ## Summary Query workflow with `current_tenant_id` to ensure the index `workflow_version_idx` can be fully utilized. Closes #31998 ## Screenshots <img width="1147" height="328" alt="image" src="https://github.com/user-attachments/assets/7de98294-7dac-4074-9abe-0a725f079e6d" /> Executed SQL: ``` 2026-02-05 10:11:51,221 INFO sqlalchemy.engine.Engine SELECT workflows.id, workflows.tenant_id, workflows.app_id, workflows.type, workflows.version, workflows.marked_name, workflows.marked_comment, workflows.graph, workflows.features, workflows.created_by, workflows.created_at, workflows.updated_by, workflows.updated_at, workflows.environment_variables, workflows.conversation_variables, workflows.rag_pipeline_variables FROM workflows WHERE workflows.version = %(version_1)s AND workflows.app_id IN (%(app_id_1_1)s::UUID, %(app_id_1_2)s::UUID, %(app_id_1_3)s::UUID, %(app_id_1_4)s::UUID, %(app_id_1_5)s::UUID, %(app_id_1_6)s::UUID, %(app_id_1_7)s::UUID, %(app_id_1_8)s::UUID, %(app_id_1_9)s::UUID, %(app_id_1_10)s::UUID, %(app_id_1_11)s::UUID, %(app_id_1_12)s::UUID, %(app_id_1_13)s::UUID, %(app_id_1_14)s::UUID, %(app_id_1_15)s::UUID, %(app_id_1_16)s::UUID, %(app_id_1_17)s::UUID, %(app_id_1_18)s::UUID, %(app_id_1_19)s::UUID, %(app_id_1_20)s::UUID, %(app_id_1_21)s::UUID, %(app_id_1_22)s::UUID, %(app_id_1_23)s::UUID, %(app_id_1_24)s::UUID, %(app_id_1_25)s::UUID, %(app_id_1_26)s::UUID, %(app_id_1_27)s::UUID) AND workflows.tenant_id = %(tenant_id_1)s::UUID ``` ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `make lint` and `make type-check` (backend) and `cd web && npx lint-staged` (frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:53:24 -05:00
yindo closed this issue 2026-02-21 20:53:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#33501