You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some scenarios, EF Core internally generates more than one read in order to execute a single query. This is notably the case when executing (some?) joins when using a non-MARS provider. Performance could be (greatly!) improved by batching those multiple reads into a single batch internally. Unless I'm mistaken, in the case you generate multiple queries, the results for the earlier queries have to be buffered anyway, so there's no additional penalty in the buffering implied in the batching.
Note: this issue isn't about exposing a batching read API to the user (that's what #10879 is about).
NOTE: batching becomes impossible if we decide to go in the direction of #12776 (fetching dependents by foreign keys instead of reevaluating the principal query).
Reacted by Andriy Svyryd, Diego Vega, Catalin Pop, Shane Krueger, Ryouko Konpaku, Brice Lambson, Pawel Gerr, Dai, Dan, Brar Piening and 34 more
Note: batching becomes impossible if we decide to go in the direction of #12776 (fetching dependents by foreign keys instead of reevaluating the principal query).
I've checked what command batching does to isolation/consistency in SQL Server and PostgreSQL, and the results are negative: merely batching statements into the same DbCommand doesn't have any impact on isolation.
If it is possible to batch split queries (i.e. no #12776) then it is possible to combine them into a single query, see #22435 (comment).
Some perf may be lost on transferring large chunks of nulls though.
@bachratyg makes sense. We definitely have to at some point think about the best strategy going forward - allowing the user to select from multiple possible ones may also be the way.
Activity
ajcvickers commentedon Feb 8, 2018
Note: see also #10465, which is very similar but comes from a slightly different angle.
divega commentedon Feb 8, 2018
See also #5952
roji commentedon Sep 25, 2019
Unless I'm mistaken, this is no longer relevant as we generate one SQL query per LINQ query since 3.0. Closing.
roji commentedon Apr 21, 2020
Reopening and assigning to @smitpatel at his request, could be done as part of the workaround for #18022.
14 remaining items
roji commentedon Mar 4, 2024
Note: batching becomes impossible if we decide to go in the direction of #12776 (fetching dependents by foreign keys instead of reevaluating the principal query).
bachratyg commentedon Jul 17, 2025
If it is possible to batch split queries (i.e. no #12776) then it is possible to combine them into a single query, see #22435 (comment).
Some perf may be lost on transferring large chunks of nulls though.
roji commentedon Jul 29, 2025
@bachratyg makes sense. We definitely have to at some point think about the best strategy going forward - allowing the user to select from multiple possible ones may also be the way.
PeterDraex commentedon Oct 26, 2025
roji commentedon Oct 26, 2025