SendBatch now uses pipeline mode to prepare and describe statements
Previously, a batch with 10 unique parameterized statements executed 100 times would entail 11 network round trips. 1 for each prepare / describe and 1 for executing them all. Now pipeline mode is used to prepare / describe all statements in a single network round trip. So it would only take 2 round trips.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/internal/stmtcache"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
"github.com/jackc/pgx/v5/pgproto3"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
@@ -173,8 +174,16 @@ func (rows *baseRows) Close() {
|
||||
}
|
||||
}
|
||||
|
||||
if rows.err != nil && rows.conn != nil && rows.conn.statementCache != nil {
|
||||
rows.conn.statementCache.StatementErrored(rows.sql, rows.err)
|
||||
if rows.err != nil && rows.conn != nil && rows.sql != "" {
|
||||
if stmtcache.IsStatementInvalid(rows.err) {
|
||||
if sc := rows.conn.statementCache; sc != nil {
|
||||
sc.Invalidate(rows.sql)
|
||||
}
|
||||
|
||||
if sc := rows.conn.descriptionCache; sc != nil {
|
||||
sc.Invalidate(rows.sql)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user