From 41dcd5d117c9289d80cd256869e0007134719ac5 Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Fri, 15 Nov 2024 14:54:28 -0800 Subject: [PATCH 1/2] disable sort for summary count --- .../Features/Search/SearchOptionsFactory.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchOptionsFactory.cs b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchOptionsFactory.cs index 37333370f6..41e695c0c3 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchOptionsFactory.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core/Features/Search/SearchOptionsFactory.cs @@ -411,7 +411,9 @@ public SearchOptions Create( searchOptions.UnsupportedSearchParams = unsupportedSearchParameters; var searchSortErrors = new List(); - if (searchParams.Sort?.Count > 0) + + // Sort is unneded for summary count + if (searchParams.Sort?.Count > 0 && searchParams.Summary != SummaryType.Count) { var sortings = new List<(SearchParameterInfo, SortOrder)>(searchParams.Sort.Count); bool sortingsValid = true; From ad78e4238cde9a9bfeaa138f43cce5e60ecd9bd9 Mon Sep 17 00:00:00 2001 From: Mikael Weaver Date: Fri, 15 Nov 2024 15:15:55 -0800 Subject: [PATCH 2/2] disable sort logic for count only --- .../Features/Search/SqlServerSearchService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Health.Fhir.SqlServer/Features/Search/SqlServerSearchService.cs b/src/Microsoft.Health.Fhir.SqlServer/Features/Search/SqlServerSearchService.cs index cdc0c4c5b8..3b4bb0d4eb 100644 --- a/src/Microsoft.Health.Fhir.SqlServer/Features/Search/SqlServerSearchService.cs +++ b/src/Microsoft.Health.Fhir.SqlServer/Features/Search/SqlServerSearchService.cs @@ -158,7 +158,7 @@ public override async Task SearchAsync(SearchOptions searchOptions // We seem to have run a sort which has returned less results than what max we can return. // Let's determine whether we need to execute another query or not. if ((sqlSearchOptions.Sort[0].sortOrder == SortOrder.Ascending && sqlSearchOptions.DidWeSearchForSortValue.HasValue && !sqlSearchOptions.DidWeSearchForSortValue.Value) || - (sqlSearchOptions.Sort[0].sortOrder == SortOrder.Descending && sqlSearchOptions.DidWeSearchForSortValue.HasValue && sqlSearchOptions.DidWeSearchForSortValue.Value && !sqlSearchOptions.SortHasMissingModifier) || (sqlSearchOptions.Sort[0].sortOrder == SortOrder.Descending && resultCount == 0)) + (sqlSearchOptions.Sort[0].sortOrder == SortOrder.Descending && sqlSearchOptions.DidWeSearchForSortValue.HasValue && sqlSearchOptions.DidWeSearchForSortValue.Value && !sqlSearchOptions.SortHasMissingModifier) || (sqlSearchOptions.Sort[0].sortOrder == SortOrder.Descending && resultCount == 0 && !sqlSearchOptions.CountOnly)) { if (sqlSearchOptions.MaxItemCount - resultCount == 0) {