package main import ( "time" "fmt" "log" "database/sql" _ "github.com/lib/pq" ) func main() { t0 := time.Now() db, err := sql.Open("postgres", "host=/run/postgresql") if err != nil { log.Fatal(err) } tx, _ := db.Begin() d1 := time.Since(t0) row := tx.QueryRow("select current_timestamp") var db_ts time.Time row.Scan(&db_ts) fmt.Println(db_ts) db.Close() d2 := time.Since(t0) fmt.Println(d1.Seconds(), "connect") fmt.Println(d2.Seconds(), "session") }