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

Notification page becomes very slow when the table is very large #32390

Closed
BoYanZh opened this issue Oct 31, 2024 · 1 comment · Fixed by #32395
Closed

Notification page becomes very slow when the table is very large #32390

BoYanZh opened this issue Oct 31, 2024 · 1 comment · Fixed by #32395
Labels
performance/speed performance issues with slow downs type/bug

Comments

@BoYanZh
Copy link
Contributor

BoYanZh commented Oct 31, 2024

Description

I hosted a Gitea instance with 1410973 rows in the notification table. Now Gitea admin needs ~6000ms to open the notification page. The slow SQL log is as follows:

Oct 31 14:50:44 git-server gitea[2883158]: 2024/10/31 14:50:44 models/db/list.go:164:]() [W] [Slow SQL Query] SELECT `id`, `user_id`, `repo_id`, `status`, `source`, `issue_id`, `commit_id`, `comment_id`, `updated_by`, `created_unix`, `updated_unix` FROM `notification` WHERE notification.user_id=? AND notification.status IN (?,?) ORDER BY notification.updated_unix DESC LIMIT 20 [70 1 3] - 5.11404742s

I tried to add an index in MySQL to temporarily fix it, CREATE INDEX idx_notification_user_status_updated ON notification(user_id, status, updated_unix DESC);. The notification page now only needs 6ms to load.

Should I do something other than adding the index manually to the table or can I create a PR to add the index to the code base?

Gitea Version

1.22.0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Use my own build from https://github.com/BoYanZh/gitea.

Database

MySQL/MariaDB

@lunny
Copy link
Member

lunny commented Oct 31, 2024

Please create a PR to add the index

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance/speed performance issues with slow downs type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants