Remove one allocation per pool query
This commit is contained in:
+10
-8
@@ -30,6 +30,8 @@ type ConnPool struct {
|
|||||||
pgTypes map[Oid]PgType
|
pgTypes map[Oid]PgType
|
||||||
pgsql_af_inet *byte
|
pgsql_af_inet *byte
|
||||||
pgsql_af_inet6 *byte
|
pgsql_af_inet6 *byte
|
||||||
|
txAfterClose func(tx *Tx)
|
||||||
|
rowsAfterClose func(rows *Rows)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConnPoolStat struct {
|
type ConnPoolStat struct {
|
||||||
@@ -68,6 +70,14 @@ func NewConnPool(config ConnPoolConfig) (p *ConnPool, err error) {
|
|||||||
p.logLevel = LogLevelNone
|
p.logLevel = LogLevelNone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.txAfterClose = func(tx *Tx) {
|
||||||
|
p.Release(tx.Conn())
|
||||||
|
}
|
||||||
|
|
||||||
|
p.rowsAfterClose = func(rows *Rows) {
|
||||||
|
p.Release(rows.Conn())
|
||||||
|
}
|
||||||
|
|
||||||
p.allConnections = make([]*Conn, 0, p.maxConnections)
|
p.allConnections = make([]*Conn, 0, p.maxConnections)
|
||||||
p.availableConnections = make([]*Conn, 0, p.maxConnections)
|
p.availableConnections = make([]*Conn, 0, p.maxConnections)
|
||||||
p.preparedStatements = make(map[string]*PreparedStatement)
|
p.preparedStatements = make(map[string]*PreparedStatement)
|
||||||
@@ -486,11 +496,3 @@ func (p *ConnPool) BeginIso(iso string) (*Tx, error) {
|
|||||||
return tx, nil
|
return tx, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ConnPool) txAfterClose(tx *Tx) {
|
|
||||||
p.Release(tx.Conn())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ConnPool) rowsAfterClose(rows *Rows) {
|
|
||||||
p.Release(rows.Conn())
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user