Skip to content

Commit

Permalink
Disable connection pooling and connection lifetime settings in mysql.go
Browse files Browse the repository at this point in the history
  • Loading branch information
moremorefun committed Jan 2, 2024
1 parent 74325f8 commit ec010be
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions mysql.go
Expand Up @@ -5,7 +5,6 @@ import (
"database/sql"
"fmt"
"reflect"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -49,10 +48,10 @@ func DbCreate(dataSourceName string, showSQL bool) *sqlx.DB {
return nil
}

count := runtime.NumCPU()*20 + 1
db.SetMaxOpenConns(count)
db.SetMaxIdleConns(count)
db.SetConnMaxLifetime(1 * time.Hour)
//count := runtime.NumCPU()*20 + 1
//db.SetMaxOpenConns(count)
//db.SetMaxIdleConns(count)
//db.SetConnMaxLifetime(1 * time.Hour)

err = db.Ping()
if err != nil {
Expand Down

0 comments on commit ec010be

Please sign in to comment.