-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pg
startup slower than pgx
obviously
#64
Comments
The pool immediately opens 5 connections. In the pgx example, you aren't using a pool. If you use pgxpool, it doesn't eagerly open connections. I believe this is a more fair test: package main
import (
"context"
"fmt"
"os"
"time"
"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
conf, err := pgxpool.ParseConfig(URI)
if err != nil {
panic(err)
}
c1 := time.Now()
dbpool, err := pgxpool.NewWithConfig(context.Background(), conf)
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err)
os.Exit(1)
}
defer dbpool.Close()
dbpool.Acquire(context.Background())
dbpool.Acquire(context.Background())
dbpool.Acquire(context.Background())
dbpool.Acquire(context.Background())
dbpool.Acquire(context.Background())
fmt.Println(time.Since(c1)) For me, pgx is still a bit faster, but it's 1.5 vs 1.7 seconds. If you still think this is an issue, I'm wondering if you're able to try without TLS (I realize this isn't practical to do, but I'm curious how much of the overhead comes from establishing TLS)? What's the ping to your DB server - If your request is to speed it up, I can think of two things pg.zig might be able to do: |
When change
The startup efficiency is not core issue, mainly of user experience. |
👍 |
Lazily initializing the connections is now controlled by the new |
[pg.zig]:
[go/pgx]:
result comparison:
The text was updated successfully, but these errors were encountered: