Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EES-5256 Opt-out of OPENJSON subquery transformation in time periods query and revert #5002 #5006

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

benoutram
Copy link
Collaborator

@benoutram benoutram commented Jun 26, 2024

This PR opts-out of the OPENJSON subquery transformation of the location id's in the time periods metadata query and revert back to using an SQL IN clause as was the behaviour prior to updating to Entity Framework Core 8.

Prior to this change the query is translated using an OPENJSON subquery

SELECT DISTINCT [o].[Year], [o].[TimeIdentifier]
 FROM [Observation] AS [o]
WHERE [o].[SubjectId] = @__8__locals1_query_SubjectId_0
AND [o].[LocationId] IN (
    SELECT [l].[value]
    FROM OPENJSON(@__locationIds_1) WITH ([value] uniqueidentifier '$') AS [l]
)

With this change, for multiple location id's the query is translated using IN

SELECT DISTINCT [o].[Year], [o].[TimeIdentifier]
FROM [Observation] AS [o]
WHERE [o].[SubjectId] = @__8__locals1_query_SubjectId_0
AND [o].[LocationId] IN ('00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000000')

For a single location id the query is now translated as

SELECT DISTINCT [o].[Year], [o].[TimeIdentifier]
FROM [Observation] AS [o]
WHERE [o].[SubjectId] = @__query_SubjectId_0
AND [o].[LocationId] = '00000000-0000-0000-0000-000000000000'

We will need to test this carefully as performance could be worse given that the constant location values in the SQL statement will result in unique query plans being generated as opposed to the previous parameterised version where the SQL statement remained constant.

Revert dependency downgrade made by #5002

This PR also reverts the changes made in #5002 which were going to downgrade EF 8.0.4 to 8.0.3 but this has not been deployed to any environment yet and is thought not be the cause of the degradation.

…e in time periods query after observing performance degradation.
…EES-5256"

This reverts commit 6369121, reversing
changes made to eda64cf.
@benoutram benoutram force-pushed the bugfix/EES-5256-2 branch from 71578b3 to 1e831f7 Compare June 26, 2024 09:57
@benoutram benoutram merged commit 4b11a4d into master Jun 26, 2024
7 checks passed
@benoutram benoutram deleted the bugfix/EES-5256-2 branch June 26, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants