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

[release/7.0] Fix to #28881 - Consider removing unnecessary CASTs around JSON_VALUE #30442

Closed
wants to merge 1 commit into from

Conversation

maumar
Copy link
Contributor

@maumar maumar commented Mar 9, 2023

Ported from #29417
Fixes #28881

Description

JSON queries returning single string properties were adding unnecessary CAST.

Customer impact

Fix improves performance and readability of affected queries. Perf impact can be significant in some cases, basically allowing for index seek instead of a scan.

How found

Found by EF Core engineers.

Regression

No. JSON support has been introduced in 7.0.

Testing

Already significant test coverage (each query test verifies SQL result), added more tests for good measure.

Risk

Minimal: Fix is very isolated, only affects specific JSON scenarios projecting varchar columns - change is to remove the cast to nvarchar(max) around columns that are already strings. Added quirk to revert to old behavior if necessary.

…und JSON_VALUE

We can remove cast for string scalars, other types maybe cause conversion issues in the generated sql.

Fixes #28881
@maumar maumar added this to the 7.0.x milestone Mar 9, 2023
@ajcvickers ajcvickers closed this Mar 14, 2023
@ajcvickers ajcvickers removed this from the 7.0.x milestone Mar 14, 2023
@maumar maumar deleted the fix28881_70 branch October 4, 2023 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants