From ec8d645fd32b009597f392b257ca3c61d4820dfd Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Thu, 12 Sep 2024 15:25:57 +0200 Subject: [PATCH] [dss] sort cell ids in queries --- pkg/sql/utils.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 }