forgejo_backup/models/forgejo_migrations/v35.go
Earl Warren debd74e1b6 fix: add an index to the ActionRun.stopped column (#8252)
The models/actions/run.go:GetRunBefore function sorts ActionRun rows to get the most recently stopped. Since the ActionRun rows do not expire, the cost will keep increasing over time.

The index is meant to ensure the execution time of the associated query does not grow linearly with the number of rows in the ActionRun table.

Ref https://codeberg.org/forgejo/forgejo/pulls/7491/files#issuecomment-5495441

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8252
Reviewed-by: Christopher Besch <mail@chris-besch.com>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
2025-06-23 08:00:18 +02:00

19 lines
387 B
Go

// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package forgejo_migrations //nolint:revive
import (
"forgejo.org/modules/timeutil"
"xorm.io/xorm"
)
func AddIndexToActionRunStopped(x *xorm.Engine) error {
type ActionRun struct {
ID int64
Stopped timeutil.TimeStamp `xorm:"index"`
}
return x.Sync(&ActionRun{})
}