Skip to content

Filter stat for ReferenceSearchParam and UriSearchParam table#5531

Open
apurvabhaleMS wants to merge 5 commits into
mainfrom
personal/abhale/filter-stat-for-reference-uri-table
Open

Filter stat for ReferenceSearchParam and UriSearchParam table#5531
apurvabhaleMS wants to merge 5 commits into
mainfrom
personal/abhale/filter-stat-for-reference-uri-table

Conversation

@apurvabhaleMS
Copy link
Copy Markdown
Contributor

@apurvabhaleMS apurvabhaleMS commented Apr 29, 2026

Description

This PR extends the SQL Server filtered statistics mechanism to cover ReferenceSearchParam and UriSearchParam tables, which were previously missing. When FHIR searches hit these tables, the query optimizer now has per-resource-type statistics for better plan selection.

dbo.ReferenceSearchParam

  • ST_ReferenceResourceId_WHERE_ResourceTypeId_40_SearchParamId_1219 — stat on the ReferenceResourceId
  • ST_ReferenceResourceTypeId_WHERE_ResourceTypeId_40_SearchParamId_414 — stat on the ReferenceResourceTypeId

dbo.UriSearchParam

  • ST_Uri_WHERE_ResourceTypeId_144_SearchParamId_1219 — stat on the Uri

Screenshots

image image

Related issues

Addresses AB189018.

Testing

Describe how this change was tested.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 65 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • Tag the PR with the type of update: Bug, Build, Dependencies, Enhancement, New-Feature or Documentation
  • Tag the PR with Open source, Azure API for FHIR (CosmosDB or common code) or Azure Healthcare APIs (SQL or common code) to specify where this change is intended to be released.
  • Tag the PR with Schema Version backward compatible or Schema Version backward incompatible or Schema Version unchanged if this adds or updates Sql script which is/is not backward compatible with the code.
  • When changing or adding behavior, if your code modifies the system design or changes design assumptions, please create and include an ADR.
  • CI is green before merge Build Status
  • Review squash-merge requirements

Semver Change (docs)

Patch|Skip|Feature|Breaking (reason)

@apurvabhaleMS apurvabhaleMS requested a review from a team as a code owner April 29, 2026 22:10
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@816452f). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5531   +/-   ##
=======================================
  Coverage        ?   77.69%           
=======================================
  Files           ?      985           
  Lines           ?    36192           
  Branches        ?     5498           
=======================================
  Hits            ?    28120           
  Misses          ?     6717           
  Partials        ?     1355           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@apurvabhaleMS apurvabhaleMS requested a review from Copilot April 30, 2026 18:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds filtered-statistics support for additional SQL search parameter tables (ReferenceSearchParam and UriSearchParam) and verifies the behavior with new unit/integration tests.

Changes:

  • Extend GetKeyColumns to include dbo.ReferenceSearchParam and dbo.UriSearchParam key columns.
  • Add unit tests covering GetKeyColumns across single/two-column tables and unknown/null tables.
  • Add integration tests asserting filtered stats are created (and skipped for :missing / NotExists expressions).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/Microsoft.Health.Fhir.Shared.Tests.Integration/Persistence/SqlServerCreateStatsTests.cs Adds integration coverage for stats creation for Reference/Uri params and for NotExists behavior.
src/Microsoft.Health.Fhir.SqlServer/Features/Search/SqlServerSearchService.cs Expands key-column mapping for filtered stats to Reference/Uri tables and shares it with the stats pipeline.
src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlServerSearchServiceTests.cs Adds unit tests validating the expanded GetKeyColumns behavior.

@apurvabhaleMS apurvabhaleMS added Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs performance No-PaaS-breaking-change No-ADR ADR not needed labels Apr 30, 2026
@apurvabhaleMS apurvabhaleMS added this to the FY26\Q4\2Wk\2Wk22 milestone Apr 30, 2026
@apurvabhaleMS apurvabhaleMS added the Enhancement Enhancement on existing functionality. label Apr 30, 2026
@SergeyGaluzo
Copy link
Copy Markdown
Contributor

I think stats on ref search param should be ST_ReferenceResourceId_WHERE_ResourceTypeId_40_SearchParamId_1219_ReferenceResourceTypeId_XXX

…i-table

# Conflicts:
#	src/Microsoft.Health.Fhir.SqlServer.UnitTests/Features/Search/SqlServerSearchServiceTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-SQL Area related to the SQL Server data provider Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Enhancement Enhancement on existing functionality. No-ADR ADR not needed No-PaaS-breaking-change performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants