Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Open
BoYanZh opened this issue Oct 31, 2024 · 1 comment · May be fixed by #32395
Open

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

BoYanZh opened this issue Oct 31, 2024 · 1 comment · May be 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

@lunny lunny added the performance/speed performance issues with slow downs label Oct 31, 2024
@lunny lunny linked a pull request Nov 1, 2024 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # 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