go-gorm / postgres

GORM PostgreSQL driver
MIT License
234 stars 123 forks source link

Establishing a connection to the database is taking around 2.5 seconds #207

Open Dviswanath560 opened 1 year ago

Dviswanath560 commented 1 year ago

Connecting to the postgres is taking almost 2.5 seconds. Is there any way that can be reduced:

import ( "fmt" "time"

"gorm.io/driver/postgres"
"gorm.io/gorm"

)

func main() { fmt.Println("starting") startTime := time.Now() dsn := "host=127.0.0.1 user=xxxx password=xxxx dbname=xxxxx port=xxxx sslmode=disable" _, err := gorm.Open(postgres.Open(dsn), &gorm.Config{ DisableAutomaticPing: true, }) fmt.Printf("Total time taken: %v ", time.Since(startTime)) }