mirror of
1
Fork 0
forgejo/models
Giteabot c3b7120042
Add index to `issue_user.issue_id` (#27154) (#27158)
Backport #27154 by @JakobDev

This fixes a performance bottleneck. It was discovered by Codeberg.
Every where query on that table (which has grown big over time) uses
this column, but there is no index on it.

See this part of the log which was posted on Matrix:
```
2023/09/10 00:52:01 ...rs/web/repo/issue.go:1446:ViewIssue() [W] [Slow SQL Query] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? [true x y] - 51.395434887s
2023/09/10 00:52:01 ...rs/web/repo/issue.go:1447:ViewIssue() [E] ReadBy: Error 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
2023/09/10 00:52:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /Codeberg/Community/issues/1201 for [::ffff:xxx]:0, 500 Internal Server Error in 52384.2ms @ repo/issue.go:1256(repo.ViewIssue)
```

Co-authored-by: JakobDev <jakobdev@gmx.de>
2023-09-21 11:42:34 +08:00
..
actions Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
activities
admin Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
asymkey
auth Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
avatars
db
dbfs
fixtures
git Search branches (#27055) 2023-09-17 08:24:40 +00:00
issues Add index to `issue_user.issue_id` (#27154) (#27158) 2023-09-21 11:42:34 +08:00
migrations Add index to `issue_user.issue_id` (#27154) (#27158) 2023-09-21 11:42:34 +08:00
organization Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
packages
perm
project
pull
repo Add `RemoteAddress` to mirrors (#26952) 2023-09-16 16:03:02 +00:00
secret
shared/types
system
unit
unittest
user Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
webhook
error.go
fixture_generation.go
fixture_test.go
main_test.go
org.go
org_team.go Use db.WithTx for AddTeamMember to avoid ctx abuse (#27095) 2023-09-16 12:54:23 +00:00
org_team_test.go
org_test.go
repo.go
repo_test.go
repo_transfer.go Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00
repo_transfer_test.go Next round of `db.DefaultContext` refactor (#27089) 2023-09-16 14:39:12 +00:00