Skip to content

Commit

Permalink
sql/catalog/descs,nstree: fix another perf problem
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
ajwerner committed Nov 15, 2021
1 parent 0faba2d commit fdc1c88
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/catalog/descs/uncommitted_descriptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ func (ud *uncommittedDescriptors) getByName(
if got := ud.descs.GetByName(dbID, schemaID, name); got != nil {
return false, got.(*uncommittedDescriptor).immutable
}
// Check whether the set is empty to avoid allocating the NameInfo.
if ud.descNames.Empty() {
return false, nil
}
return ud.descNames.Contains(descpb.NameInfo{
ParentID: dbID,
ParentSchemaID: schemaID,
Expand Down
5 changes: 5 additions & 0 deletions pkg/sql/catalog/nstree/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (s *Set) Clear() {
*s = Set{}
}

// Empty returns true if the set has no entries.
func (s *Set) Empty() bool {
return !s.initialized() || s.t.Len() == 0
}

func (s *Set) maybeInitialize() {
if s.initialized() {
return
Expand Down

0 comments on commit fdc1c88

Please sign in to comment.