Skip to content

Commit

Permalink
sql/sqlinstance/instancestorage: use CommitInBatch to optimize round-…
Browse files Browse the repository at this point in the history
…trips

By using CommitInBatch we can hit the 1PC optimization and avoid a round-trip
to the leaseholder of the range in question.

Release note: None
  • Loading branch information
ajwerner committed Jul 21, 2022
1 parent 5e53f01 commit 066edbe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/sql/sqlinstance/instancestorage/instancestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ func (s *Storage) CreateInstance(
log.Warningf(ctx, "failed to encode row for instance id %d: %v", instanceID, err)
return err
}
return txn.Put(ctx, row.Key, row.Value)
b := txn.NewBatch()
b.Put(row.Key, row.Value)
return txn.CommitInBatch(ctx, b)
})

if err != nil {
Expand Down

0 comments on commit 066edbe

Please sign in to comment.