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
Query Future does not seem to work as expected. Two DB calls being made #793
Comments
Hello @OliverRC , Thank you for reporting. Looking at the code, Best Regards, Jon |
Hey, I was wondering if maybe it was a MySql related issue. This is why I tried MSSQL hoping for a better result. Unfortunately, as you can see it doesn't seem to work there either. It would be a real pity if the Plus library doesn't work with Pomelo as your Extensions library is working perfectly with Pomelo (MySql) |
Do you have any feedback as this feature did not seem to work on MSSQL which is EF's primary database driver? |
Hello @OliverRC , It should already work on MSSQL. If you have an issue with this provider, could you create a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue. However, it was indeed disabled for |
I have created a minimal example |
Hello @OliverRC , It worked great on our side for SQL Server: exec sp_executesql N'-- EF+ Query Future: 1 of 2
SELECT [p].[Id], [p].[Email], [p].[Name], [p].[ShirtSize]
FROM [People] AS [p]
ORDER BY (SELECT 1)
OFFSET @Z_1___p_0 ROWS FETCH NEXT @Z_1___p_1 ROWS ONLY
;
-- EF+ Query Future: 2 of 2
SELECT COUNT(*)
FROM [People] AS [p]
;
',N'@Z_1___p_0 int,@Z_1___p_1 int',@Z_1___p_0=0,@Z_1___p_1=10 Only 1 SQL has been executed. |
[1]
So it look like the MSSQL integration is indeed working. I am going to dig a little deeper into tracing/profiling MariaDB/MySQL. [2] |
Looking at the MariaDB log:
It looks like two separate queries
|
I am following up as I haven't had any responses to my latest findings. TLDR: [1] EF Core seems to log the queries as two separate commands even though Futures work on MSSQL? [2] We are a paid customer of EF Extensions which does support |
Hello @OliverRC , My bad, this request was a little bit lost on our side. We were waiting for the answer about the SQL Server provided, which you confirmed last week was working. The fix for However, the new version will only be released in around 2 or 3 weeks (Should be April 9 or April 16). Best Regards, Jon |
Hello @OliverRC , The v8.102.2.2 is now available. Could you try it and let us know if everything is now working as expected? Best Regards, Jon |
Hey @JonathanMagnan so I've done some testing. [1] -- EF+ Query Future: 1 of 2
SELECT `p`.`Id`, `p`.`Email`, `p`.`Name`, `p`.`ShirtSize`
FROM `People` AS `p`
ORDER BY `p`.`Id`
LIMIT @Z_1___p_1 OFFSET @Z_1___p_0
;
-- EF+ Query Future: 2 of 2
SELECT COUNT(*)
FROM `People` AS `p`
; Performance locally seems worseThat is great. On the newer version, even though the SQL is merged, the actual performance (albeit on a very simple example locally) seems slower. The old version is faster with the two separate calls. BenchmarksI was going to run benchmarks however I think that the version I was using |
Hello @OliverRC , You can turn off query batch with the following options: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/src/shared/Z.EF.Plus.QueryFuture.Shared/QueryFutureManager.cs#L54 Version are always available on NuGet, just hidden: https://www.nuget.org/packages/Z.EntityFramework.Plus.EFCore/8.102.1 As for the performance issue, there is not much we can do here. We know that some providers take longer to create the query plan as the query gets more complex. Best Regards, Jon |
Thanks for the guidance on the configuration. I'd like to run the updated version with Future on our actual codebase and maybe compare performance in both modes to see what suits our performance profile best. As for performance, I guess that is interesting that it falls to the provider building the query plan. I guess that's what that "empty" space is on the trace. Thank you for your detailed assistance, it is greatly appreciated. |
Awesome, Let me know about your results; I would be interested to hear your thoughts. Best Regards, Jon |
1. Description
I followed the documentation on Query Future in order to optimize my pagination queries. However, I am not able to get the desired behavior to work.
The expectation was that both queries would be executed together in a single execute step.
2. Example code
3. Issue
However, I see two separate database calls and executions that waterfall one after the other.
I have tested with both
MSSQLand MariaDB (MySql)To aid in debugging, I added .NET Aspire to a minimal example, and the following is the database call trace.
MariaDB
MSSQLAs you can see, despite following the documentation, two separate calls are still being made.
4. Project
I've tried to produce a minimal example. Here is the GitHub project.
Might require the latest VS2022 preview for aspire preview 3 bits.
https://github.com/OliverRC/QueryFutureIssue
Further technical details
SQL Server 2022/ MariaDB 11.2.3]Microsoft.EntityFrameworkCore.SqlServer v8.0.2/ Pomelo.EntityFrameworkCore.MySql v8.0.0]The text was updated successfully, but these errors were encountered: