Trying to reduce memory allocation. logQueryArgs is called even when
using the default discardLogger. This allocates quite a bit of memory. Created a default dlogger instance and avoid logging code when that's our logger. I couldn't think of a better implementation without touching the Logger interface. On 100 000 inserts, this brought the allocation down to 58MB from 122MB. It should also result in some small performance gains.
This commit is contained in:
@@ -68,6 +68,10 @@ func (rows *Rows) close() {
|
||||
|
||||
rows.closed = true
|
||||
|
||||
if rows.logger == dlogger {
|
||||
return
|
||||
}
|
||||
|
||||
if rows.err == nil {
|
||||
endTime := time.Now()
|
||||
rows.logger.Info("Query", "sql", rows.sql, "args", logQueryArgs(rows.args), "time", endTime.Sub(rows.startTime), "rowCount", rows.rowCount)
|
||||
|
||||
Reference in New Issue
Block a user