Open
Description
It has caught my attention that the use of the OPENJSON
function is causing performance regressions in EF8, as reported in dotnet/efcore#32394. This seems to be caused by the opaque nature of the function to the query engine, which could result in suboptimal execution plans.
QueryableValues currently depends on both OPENJSON
and XML methods for functionality, and thus, it is impacted to some degree by these issues.
Here are some potential solutions to address this problem:
- For large collections, project the deserialized values to a temp table and use the temp table instead. This should enable statistics, which in turn should generate optimal execution plans. However, it may cause execution plan re-compilations and result in higher latency.
- For small collections, avoid the use of deserialization functions and instead switch to a multi-parameter approach. This approach should generate optimal execution plans and maintain low latency.
These two approaches aim to provide the query engine with sufficient information to generate optimal execution plans, which is a priority. Consequently, this behavior should be enabled by default, with an option for users to opt out if desired.