BlazarTech.QueryableValues icon indicating copy to clipboard operation
BlazarTech.QueryableValues copied to clipboard

Better execution plans

Open yv989c opened this issue 2 years ago • 3 comments

It has caught my attention that the use of the OPENJSON function is causing performance regressions in EF8, as reported in https://github.com/dotnet/efcore/issues/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.

yv989c avatar Jan 04 '24 00:01 yv989c

Hi @yv989c ,

thanks for building this awesome library. The described improvement would help us a lot, any plans to work on this issue in the next time?

Best

Nils

nilzzzzzz avatar Aug 14 '24 07:08 nilzzzzzz

Hi @yv989c ,

thanks for building this awesome library. The described improvement would help us a lot, any plans to work on this issue in the next time?

Best

Nils

Hi @nilzzzzzz,

First, thanks for the kind words.

Just an update on this: Yes, I've invested a lot of time working on this with good results, but I decided to pause to see how the EF team would address it. It seems clear now that they won't be providing the level of integration I've developed to make this work well with SQL Server. That said, if I release this, it will likely be under a different license model. Unfortunately, it’s not sustainable for me to continue putting this level of effort out there completely for free.

yv989c avatar Aug 18 '24 08:08 yv989c

Hi @yv989c ,

this sounds reasonable to me and thank you for your feedback. If the licence model fees work with our business model, we are happy to support you.

nilzzzzzz avatar Aug 20 '24 06:08 nilzzzzzz