Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move issue pin to an standalone table for querying performance #33452

Merged
merged 17 commits into from
Feb 17, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Jan 31, 2025

Noticed a SQL in gitea.com has a bigger load. It seems both is_pull and pin_order are not indexed columns in the database.

SELECT `id`, `repo_id`, `index`, `poster_id`, `original_author`, `original_author_id`, `name`, `content`, `content_version`, `milestone_id`, `priority`, `is_closed`, `is_pull`, `num_comments`, `ref`, `pin_order`, `deadline_unix`, `created_unix`, `updated_unix`, `closed_unix`, `is_locked`, `time_estimate` FROM `issue` WHERE (repo_id =?) AND (is_pull = 0) AND (pin_order > 0) ORDER BY pin_order

I came across a comment #24406 (comment) from @delvh , which presents a more reasonable approach. Based on this, this PR will migrate all issue and pull request pin data from the issue table to the issue_pin table. This change benefits larger Gitea instances by improving scalability and performance.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 31, 2025
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 31, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations labels Jan 31, 2025
@lunny lunny marked this pull request as ready for review February 3, 2025 21:14
@lunny lunny requested a review from delvh February 3, 2025 21:14
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 5, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 6, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 6, 2025
@wxiaoguang wxiaoguang removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 6, 2025
@wxiaoguang wxiaoguang marked this pull request as draft February 6, 2025 03:13
@wxiaoguang wxiaoguang marked this pull request as ready for review February 10, 2025 19:35
@wxiaoguang wxiaoguang marked this pull request as draft February 10, 2025 19:35
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Some problems are from legacy code, I guess it's fine to accept them.

@lunny lunny marked this pull request as ready for review February 17, 2025 06:22
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 17, 2025
@lunny lunny merged commit 7df09e3 into go-gitea:main Feb 17, 2025
26 checks passed
@GiteaBot GiteaBot added this to the 1.24.0 milestone Feb 17, 2025
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 17, 2025
@lunny lunny deleted the lunny/move_issue_pin branch February 17, 2025 19:30
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 18, 2025
* giteaofficial/main:
  Make actions URL in commit status webhooks absolute (go-gitea#33620)
  Refactor error system (go-gitea#33626)
  Move issue pin to an standalone table for querying performance (go-gitea#33452)
  Run spellcheck on tools directory (go-gitea#33627)
  Refactor error system (go-gitea#33610)
  Fix project issues list and counting (go-gitea#33594)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/migrations size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants