diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-10-21 14:26:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 14:26:23 +0800 |
commit | 985a39590ba07798dd6e6097e0c10401764c27fb (patch) | |
tree | 2f33eb1355da1561a7d74b32806e21f08da73dc3 /models | |
parent | 2112eb87414fb0a08d77ad018ca306cfd15d5761 (diff) | |
download | gitea-985a39590ba07798dd6e6097e0c10401764c27fb.tar.gz gitea-985a39590ba07798dd6e6097e0c10401764c27fb.zip |
Use buffersize to reduce database connection when iterate (#2724)
* use buffersize to reduce database connection when iterate
* fix typo
* add default value on app.ini comment
Diffstat (limited to 'models')
-rw-r--r-- | models/migrations/v19.go | 2 | ||||
-rw-r--r-- | models/migrations/v22.go | 2 | ||||
-rw-r--r-- | models/migrations/v26.go | 2 | ||||
-rw-r--r-- | models/repo.go | 4 | ||||
-rw-r--r-- | models/user.go | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/models/migrations/v19.go b/models/migrations/v19.go index 0edeb3e92e..44338eb8ba 100644 --- a/models/migrations/v19.go +++ b/models/migrations/v19.go @@ -42,7 +42,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) { } ) - return x.Where("id > 0").Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/migrations/v22.go b/models/migrations/v22.go index 17709496e1..7774f6fd9a 100644 --- a/models/migrations/v22.go +++ b/models/migrations/v22.go @@ -42,7 +42,7 @@ func generateAndMigrateWikiGitHooks(x *xorm.Engine) (err error) { } ) - return x.Where("id > 0").Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/migrations/v26.go b/models/migrations/v26.go index 8b1c9a6326..636d1f76ca 100644 --- a/models/migrations/v26.go +++ b/models/migrations/v26.go @@ -36,7 +36,7 @@ func generateAndMigrateGitHookChains(x *xorm.Engine) (err error) { hookTpl = fmt.Sprintf("#!/usr/bin/env %s\ndata=$(cat)\nexitcodes=\"\"\nhookname=$(basename $0)\nGIT_DIR=${GIT_DIR:-$(dirname $0)}\n\nfor hook in ${GIT_DIR}/hooks/${hookname}.d/*; do\ntest -x \"${hook}\" || continue\necho \"${data}\" | \"${hook}\"\nexitcodes=\"${exitcodes} $?\"\ndone\n\nfor i in ${exitcodes}; do\n[ ${i} -eq 0 ] || exit ${i}\ndone\n", setting.ScriptType) ) - return x.Where("id > 0").Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/repo.go b/models/repo.go index 293f251d3e..1b1be62f87 100644 --- a/models/repo.go +++ b/models/repo.go @@ -2145,7 +2145,7 @@ func GitFsck() { log.Trace("Doing: GitFsck") if err := x. - Where("id>0"). + Where("id>0").BufferSize(setting.IterateBufferSize). Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) @@ -2167,7 +2167,7 @@ func GitFsck() { func GitGcRepos() error { args := append([]string{"gc"}, setting.Git.GCArgs...) return x. - Where("id > 0"). + Where("id > 0").BufferSize(setting.IterateBufferSize). Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) diff --git a/models/user.go b/models/user.go index f0cdc74d05..835a775ebc 100644 --- a/models/user.go +++ b/models/user.go @@ -816,7 +816,7 @@ func ChangeUserName(u *User, newUserName string) (err error) { } // Delete all local copies of repository wiki that user owns. - if err = x. + if err = x.BufferSize(setting.IterateBufferSize). Where("owner_id=?", u.ID). Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) |