Skip to content

Commit e85c353

Browse files
committed
sql/sem/tree: eliminate types.T allocations in collated string comparison
This commit eliminates allocations of `types.T` in the `CompareError` method of `DCollatedString`. Instead of allocating a new collated string type and calling the `Equivalent` method on the type, `CompareError` simply checks that the locales of the collated string datums match. This matches the behavior of `Equivalent`. Release note (performance improvement): Queries that compare collated strings now use less memory and may execute faster.
1 parent f464c06 commit e85c353

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/sql/sem/tree/datum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ func (d *DCollatedString) CompareError(ctx CompareContext, other Datum) (int, er
14811481
return 1, nil
14821482
}
14831483
v, ok := ctx.UnwrapDatum(other).(*DCollatedString)
1484-
if !ok || !d.ResolvedType().Equivalent(other.ResolvedType()) {
1484+
if !ok || !lex.LocaleNamesAreEqual(d.Locale, v.Locale) {
14851485
return 0, makeUnsupportedComparisonMessage(d, other)
14861486
}
14871487
res := bytes.Compare(d.Key, v.Key)

0 commit comments

Comments
 (0)