forked from kevadesu/forgejo
[GITEA] Use join for the deleting issue actions query
- The action tables can become very large as it's a dumpster for every action that an user does on an repository. - The following query: `DELETE FROM action WHERE comment_id IN (SELECT id FROM comment WHERE issue_id=?)` is not using indexes for `comment_id` and is instead using an full table scan by MariaDB. - Rewriting the query to use an JOIN will allow MariaDB to use the index. - More information: https://codeberg.org/Codeberg-Infrastructure/techstack-support/issues/9 (cherry picked from commit6646fcf31f
) Conflicts: tests/integration/api_nodeinfo_test.go https://codeberg.org/forgejo/forgejo/pulls/1178 (cherry picked from commit6465b74632
)
This commit is contained in:
parent
f27167469e
commit
95b1079e36
6 changed files with 45 additions and 7 deletions
|
@ -242,6 +242,15 @@ func TestGetFeedsCorrupted(t *testing.T) {
|
|||
assert.Equal(t, int64(0), count)
|
||||
}
|
||||
|
||||
func TestDeleteIssueActions(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
comment := unittest.AssertExistsAndLoadBean(t, &issue_model.Comment{ID: 8})
|
||||
unittest.AssertExistsAndLoadBean(t, &activities_model.Action{ID: 10, CommentID: comment.ID})
|
||||
assert.NoError(t, activities_model.DeleteIssueActions(db.DefaultContext, 32, 17))
|
||||
unittest.AssertNotExistsBean(t, &activities_model.Action{ID: 10, CommentID: comment.ID})
|
||||
}
|
||||
|
||||
func TestConsistencyUpdateAction(t *testing.T) {
|
||||
if !setting.Database.Type.IsSQLite3() {
|
||||
t.Skip("Test is only for SQLite database.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue