Skip to content

Conversation

@rajithaalurims
Copy link
Contributor

Description

A new Nullable column DecompressedLength added to Resource table.
This will be used to store size of raw resource before compressing it.
This change is both backward and forward compatible.
Checking schema version before passing additional parameter to MergeResource SP to avoid "Procedure or function 'MergeResources' has too many arguments specified." error.

Related issues

Addresses [issue #156583].

Testing

Tested with old code new schema and new code old schema

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)

@rajithaalurims rajithaalurims added this to the FY26\Q2\2Wk\2Wk11 milestone Nov 21, 2025
@rajithaalurims rajithaalurims requested a review from a team as a code owner November 21, 2025 22:10
@rajithaalurims rajithaalurims added Enhancement Enhancement on existing functionality. Azure Healthcare APIs Label denotes that the issue or PR is relevant to the FHIR service in the Azure Healthcare APIs Schema Version backward compatible labels Nov 21, 2025
@github-actions github-actions bot added the SQL Scripts If SQL scripts are added to the PR label Nov 21, 2025
,@TokenQuantityCompositeSearchParams dbo.TokenQuantityCompositeSearchParamList READONLY
,@TokenStringCompositeSearchParams dbo.TokenStringCompositeSearchParamList READONLY
,@TokenNumberNumberCompositeSearchParams dbo.TokenNumberNumberCompositeSearchParamList READONLY
,@DecompressedOverridesJson NVARCHAR(MAX) = NULL
Copy link
Contributor

Choose a reason for hiding this comment

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

Parsing JSON on each merge call sounds expensive. Instead, we should add decompressed length to ResourceList table type. There should be multiple iterations to get compatibility and final clean state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was debating between changing ResourceList table type but as you mentioned that needs multiple iterations of code release to get final clean slate.
From what I have researched additional cost for parsing takes around few hundred milli seconds for rows around 10000.
I will discuss offline with you about which option to go with

Copy link
Contributor

@SergeyGaluzo SergeyGaluzo Nov 25, 2025

Choose a reason for hiding this comment

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

Maybe. But imagine that we start adding extra JSON vars for each new column we add... This looks like antipattern. Also, there are extra joins to @Resources, and they are extra cost too... All of these are just not applicable to the case of table type change. BTW You should get fully functioning code on first iteration...

TransactionId bigint NULL,
HistoryTransactionId bigint NULL
HistoryTransactionId bigint NULL,
DecompressedLength decimal(36,18) NULL
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it cannot be int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should have used INT. I will change

BEGIN TRY
INSERT INTO dbo.Parameters (Id, Char) SELECT 'Adding DecompressedLength', 'LogEvent'
EXECUTE dbo.LogEvent @Process='Adding DecompressedLength',@Status='Start'
BEGIN TRANSACTION
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see why transaction is needed. Please explain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I want to drop and recreate procedure in the same transaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need to drop/create, but use alter. If you break up the transaction, what negative effects do you expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. Schema Version backward compatible SQL Scripts If SQL scripts are added to the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants