1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 10:18:38 +00:00

Optimize total count of feed when loading activities in user dashboard. (#33841)

Two SQLs are very slow when `action` table have over 5M records.

```
database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp"

database duration=1.5408s db.sql="SELECT count(*) FROM `action` WHERE (user_id = ?) AND (is_deleted = ?)"
```

This will cache the count for the first loading or when the activities
changed.
This commit is contained in:
Lunny Xiao
2025-03-20 10:46:18 -07:00
committed by GitHub
parent ef0970506f
commit a4df01b580
4 changed files with 46 additions and 7 deletions

View File

@@ -445,6 +445,7 @@ type GetFeedsOptions struct {
OnlyPerformedBy bool // only actions performed by requested user
IncludeDeleted bool // include deleted actions
Date string // the day we want activity for: YYYY-MM-DD
DontCount bool // do counting in GetFeeds
}
// ActivityReadable return whether doer can read activities of user