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
Currently, if we want to use GraphDiff to update a list of entities, we can only do this in a loop. Is it efficient, given that each graph is loaded by a separate request to the database? Can we make it better if we load a list of entities by a single query?
The text was updated successfully, but these errors were encountered:
I haven't thought this through at all, but yes, probably. Have a look at the line of GraphDiffer that's loading the persisted graph via QueryLoader. I'd imagine one could quite easily create an overload to load a collection of graphs using a single query..
I tried out this idea and it works great in my projects. A large batch process that updates thousands of complex graphs went from 34 to 2 minutes with a batch size of 100. I think I can downgrade to smaller Azure instances :-)
This were my changes (see fork):
changing IGraphDiffer and IQueryLoader from T to IEnumerable<T>
added additional extension method to DbContextExtensions (existing interfaces not changed)
creation of key predicate expression has to be extended to load all persisted entities at once
order of persisted/loaded entities can be different from updating entities and must be restored
prevent loading of new entities (see pull request)
All existing tests run fine with my changes to GraphDiffer and QueryLoader. Composite keys are still supported ((KeyA='a1' AND KeyB='b1') OR (KeyA='a2' AND KeyB='b2' OR ...) and simple int keys are optimized to ...Key in (1,2,3,4,5...).
Currently, if we want to use GraphDiff to update a list of entities, we can only do this in a loop. Is it efficient, given that each graph is loaded by a separate request to the database? Can we make it better if we load a list of entities by a single query?
The text was updated successfully, but these errors were encountered: