mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-25 00:50:31 +00:00
sqlite: execute PRAGMA optimize on startup
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
db35a55a3d
commit
1b928ef6b2
1 changed files with 9 additions and 1 deletions
|
@ -215,7 +215,7 @@ func initializeSQLiteProvider(basePath string) error {
|
||||||
providerLog(logger.LevelDebug, "sqlite database handle created, connection string: %q", connectionString)
|
providerLog(logger.LevelDebug, "sqlite database handle created, connection string: %q", connectionString)
|
||||||
dbHandle.SetMaxOpenConns(1)
|
dbHandle.SetMaxOpenConns(1)
|
||||||
provider = &SQLiteProvider{dbHandle: dbHandle}
|
provider = &SQLiteProvider{dbHandle: dbHandle}
|
||||||
return nil
|
return executePragmaOptimize(dbHandle)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *SQLiteProvider) checkAvailability() error {
|
func (p *SQLiteProvider) checkAvailability() error {
|
||||||
|
@ -773,6 +773,14 @@ func (p *SQLiteProvider) normalizeError(err error, fieldType int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func executePragmaOptimize(dbHandle *sql.DB) error {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), defaultSQLQueryTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
_, err := dbHandle.ExecContext(ctx, "PRAGMA optimize;")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
/*func setPragmaFK(dbHandle *sql.DB, value string) error {
|
/*func setPragmaFK(dbHandle *sql.DB, value string) error {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), longSQLQueryTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), longSQLQueryTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
Loading…
Reference in a new issue