go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.25k stars 5.5k forks source link

MariaDb: Slow Sql Query from notification table #32491

Closed sebastian-sauer closed 1 week ago

sebastian-sauer commented 1 week ago

Description

We get nearly every 30seconds the following slow query log in our log files:

...ties/notification.go:296:GetUIDsAndNotificationCounts() [W] [Slow SQL Query] SELECT user_id, sum(case when status= ? then 1 else 0 end) AS count FROM notification WHERE user_id IN (SELECT user_id FROM notification WHERE updated_unix >= ? AND updated_unix < ?) GROUP BY user_id [1 1731479575 1731479585] - 8.191264092s

Gitea Version

1.22.3

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?

Binary

Database

MySQL/MariaDB

lunny commented 1 week ago

Duplicate of #32390 and resolved by #32395

sebastian-sauer commented 1 week ago

Yes - i can confirm that the index mentioned in the PR solves the problem. Thanks