java-topology/defects/cockroach/patch/cockroach-0001-indexes-used-add-quadratic.patch

39 lines
981 B
Diff

# UNDF: UNDF-2026-000000753
# UNDF:
--- a/pkg/sql/opt/exec/execbuilder/builder.go
+++ b/pkg/sql/opt/exec/execbuilder/builder.go
@@ -7,7 +7,6 @@ package execbuilder
import (
"context"
- "slices"
"strconv"
"time"
@@ -197,14 +197,20 @@ type IndexesUsed struct {
indexes []struct {
tableID cat.StableID
indexID cat.StableID
}
+ seen map[[2]cat.StableID]struct{}
}
// add adds the given index to the list, if it is not already present.
func (iu *IndexesUsed) add(tableID, indexID cat.StableID) {
- s := struct {
- tableID cat.StableID
- indexID cat.StableID
- }{tableID, indexID}
- if !slices.Contains(iu.indexes, s) {
- iu.indexes = append(iu.indexes, s)
+ key := [2]cat.StableID{tableID, indexID}
+ if iu.seen == nil {
+ iu.seen = make(map[[2]cat.StableID]struct{})
+ }
+ if _, ok := iu.seen[key]; !ok {
+ iu.seen[key] = struct{}{}
+ iu.indexes = append(iu.indexes, struct {
+ tableID cat.StableID
+ indexID cat.StableID
+ }{tableID, indexID})
}
}