mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Handle large and all entity queries (#3544)
* Remove upper page size limit * Batch GetMany function * Remove upper query limit from UI
This commit is contained in:
20
pkg/sqlite/batch.go
Normal file
20
pkg/sqlite/batch.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package sqlite
|
||||
|
||||
const defaultBatchSize = 1000
|
||||
|
||||
// batchExec executes the provided function in batches of the provided size.
|
||||
func batchExec(ids []int, batchSize int, fn func(batch []int) error) error {
|
||||
for i := 0; i < len(ids); i += batchSize {
|
||||
end := i + batchSize
|
||||
if end > len(ids) {
|
||||
end = len(ids)
|
||||
}
|
||||
|
||||
batch := ids[i:end]
|
||||
if err := fn(batch); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user