lib/storage: handle common case when the number of rows passed to flushRowsToInmemoryParts() doesnt exceed maxRawRowsPerShard

This commit is contained in:
Aliaksandr Valialkin 2024-02-22 20:44:11 +02:00
parent 73f0a805e2
commit e8b3045062
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB

View file

@ -506,8 +506,17 @@ func (pt *partition) flushRowsToInmemoryParts(rows []rawRow) {
return
}
// Merge rows into in-memory parts.
maxRows := maxRawRowsPerShard
if len(rows) <= maxRows {
// Common case - convert rows to a single in-memory part
pw := pt.createInmemoryPart(rows)
if pw != nil {
pt.addToInmemoryParts(pw)
}
return
}
// Merge rows into in-memory parts.
var pwsLock sync.Mutex
pws := make([]*partWrapper, 0, (len(rows)+maxRows-1)/maxRows)
wg := getWaitGroup()