Skip to content

Conversation

@fanzhenyu95
Copy link

Purpose of the pull request

close #17755

Brief change log

Add the following indexes to improve the pagination query performance:

For t_ds_workflow_instance table:

  • idx_project_code_start_time (project_code, start_time DESC, id DESC)
  • idx_workflow_definition_code_start_time (workflow_definition_code, start_time DESC)

For t_ds_task_instance table:

  • idx_project_code_submit_time (project_code, submit_time DESC)
  • idx_project_code_start_time (project_code, start_time DESC)

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@boring-cyborg
Copy link

boring-cyborg bot commented Nov 29, 2025

Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe what issues you have encountered so that everyone can understand clearly what problems this PR has solved. @fanzhenyu95

@SbloodyS SbloodyS changed the title [Improvement-17755][Dao]optimize pagination query performance by addi… [Improvement-17755][Dao] Optimize pagination query performance by addi… Dec 1, 2025
@ruanwenjun
Copy link
Member

Adding indexes alone won't solve all problems; we still need to optimize some query methods to achieve better results. Please first describe which interfaces you are currently experiencing slow query issues with.

@fanzhenyu95
Copy link
Author

@SbloodyS @ruanwenjun Thank you for your feedback! The pagination queries for project list, workflow instance list, and task instance list are significantly slow in production environments with large datasets, leading to long page loading times and poor user experience.

Frequently used interfaces with slow query performance include:

  1. Project list API: GET /projects
  2. Workflow instance list API: GET /projects/{projectCode}/workflow-instances
  3. Task instance list API: GET /projects/{projectCode}/task-instances

While adding indexes alone may not solve all performance issues, in our specific scenario with tables containing millions of records, list queries were taking over 10 seconds to execute and sometimes even failed to return results. After implementing the proposed indexes, all list queries now perform normally with acceptable response times.

@ruanwenjun ruanwenjun changed the title [Improvement-17755][Dao] Optimize pagination query performance by addi… [Improvement-17755][Dao] Optimize pagination query performance of projects/workflow-instances/task-instances Dec 15, 2025
@ruanwenjun ruanwenjun force-pushed the dev_fanzhenyu_addIndex branch from a31ac50 to 2c95045 Compare December 15, 2025 07:44
@ruanwenjun
Copy link
Member

@fanzhenyu95 Thanks for the clarification. I've updated the issue and PR titles.

@ruanwenjun ruanwenjun added the improvement make more easy to user or prompt friendly label Dec 15, 2025
@ruanwenjun ruanwenjun added this to the 3.4.0 milestone Dec 15, 2025
Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema Check failed. Please fix it. @fanzhenyu95

@sonarqubecloud
Copy link

Copy link
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema Test failed. Please fix it. @fanzhenyu95

@SbloodyS SbloodyS modified the milestones: 3.4.0, 3.4.1 Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][Dao] Optimize pagination query performance of projects/workflow-instances/task-instances

3 participants