There are a lot of database query operations. Can I go to cache? #11945

Closed
opened 2026-02-21 19:04:53 -05:00 by yindo · 2 comments
Owner

Originally created by @jiangbo721 on GitHub (Mar 21, 2025).

Originally assigned to: @laipz8200 on GitHub.

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

There are so many codes like this:

    app = (
        db.session.query(App)
        .filter(App.id == app_id, App.tenant_id == current_user.current_tenant_id, App.status == "normal")
        .first()
    )

    if not app:
        raise NotFound("App not found")

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @jiangbo721 on GitHub (Mar 21, 2025). Originally assigned to: @laipz8200 on GitHub. ### Self Checks - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. There are so many codes like this: app = ( db.session.query(App) .filter(App.id == app_id, App.tenant_id == current_user.current_tenant_id, App.status == "normal") .first() ) if not app: raise NotFound("App not found") ### 2. Additional context or comments _No response_ ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the stale label 2026-02-21 19:04:53 -05:00
yindo closed this issue 2026-02-21 19:04:53 -05:00
Author
Owner

@laipz8200 commented on GitHub (Mar 31, 2025):

IMO, use index correctly is enough for those scenarios. We don't need more cache for the simple query, because manage cache will be a heavy work.

@laipz8200 commented on GitHub (Mar 31, 2025): IMO, use index correctly is enough for those scenarios. We don't need more cache for the simple query, because manage cache will be a heavy work.
Author
Owner

@dosubot[bot] commented on GitHub (May 2, 2025):

Hi, @jiangbo721. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • Proposal to implement caching to optimize performance by reducing database queries.
  • You expressed interest in contributing to this feature.
  • @laipz8200 suggested that proper indexing might suffice for simple queries and cautioned about the complexity of cache management.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of the Dify repository by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (May 2, 2025): Hi, @jiangbo721. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - Proposal to implement caching to optimize performance by reducing database queries. - You expressed interest in contributing to this feature. - @laipz8200 suggested that proper indexing might suffice for simple queries and cautioned about the complexity of cache management. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of the Dify repository by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#11945