Allocate connRows on demand instead of preallocating in bulk
The 64 element preallocatedRows may be pinning memory from previous queries. See https://github.com/jackc/pgx/issues/1127
This commit is contained in:
committed by
Jack Christensen
parent
1e565b0d44
commit
b6b24f9e8a
@@ -73,9 +73,8 @@ type Conn struct {
|
|||||||
|
|
||||||
connInfo *pgtype.ConnInfo
|
connInfo *pgtype.ConnInfo
|
||||||
|
|
||||||
wbuf []byte
|
wbuf []byte
|
||||||
preallocatedRows []connRows
|
eqb extendedQueryBuilder
|
||||||
eqb extendedQueryBuilder
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identifier a PostgreSQL identifier or name. Identifiers can be composed of
|
// Identifier a PostgreSQL identifier or name. Identifiers can be composed of
|
||||||
@@ -513,12 +512,7 @@ func (c *Conn) execPrepared(ctx context.Context, sd *pgconn.StatementDescription
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *connRows {
|
func (c *Conn) getRows(ctx context.Context, sql string, args []interface{}) *connRows {
|
||||||
if len(c.preallocatedRows) == 0 {
|
r := &connRows{}
|
||||||
c.preallocatedRows = make([]connRows, 64)
|
|
||||||
}
|
|
||||||
|
|
||||||
r := &c.preallocatedRows[len(c.preallocatedRows)-1]
|
|
||||||
c.preallocatedRows = c.preallocatedRows[0 : len(c.preallocatedRows)-1]
|
|
||||||
|
|
||||||
r.ctx = ctx
|
r.ctx = ctx
|
||||||
r.logger = c
|
r.logger = c
|
||||||
|
|||||||
Reference in New Issue
Block a user