diff --git a/pkg/sql/utils.go b/pkg/sql/utils.go index 420107602..513f85d91 100644 --- a/pkg/sql/utils.go +++ b/pkg/sql/utils.go @@ -1,10 +1,10 @@ package sql import ( + "github.com/golang/geo/s2" "github.com/interuss/dss/pkg/geo" "github.com/interuss/stacktrace" - - "github.com/golang/geo/s2" + "slices" ) func CellUnionToCellIds(cu s2.CellUnion) []int64 { @@ -13,6 +13,8 @@ func CellUnionToCellIds(cu s2.CellUnion) []int64 { // TODO consider validating the cell here: it is/was done in many similar conversion loops pgCids[i] = int64(cell) } + // Sort the cell IDs for optimisation purpose (see https://github.com/interuss/dss/issues/814) + slices.Sort(pgCids) return pgCids } @@ -24,5 +26,7 @@ func CellUnionToCellIdsWithValidation(cu s2.CellUnion) ([]int64, error) { } pgCids[i] = int64(cell) } + // Sort the cell IDs for optimisation purpose (see https://github.com/interuss/dss/issues/814) + slices.Sort(pgCids) return pgCids, nil }