-
Notifications
You must be signed in to change notification settings - Fork 933
Optimize batchable cache calls for cached queries #1955
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
Optimize batchable cache calls for cached queries #1955
Conversation
This comment has been minimized.
This comment has been minimized.
009f0a2
to
e687bbe
Compare
This comment has been minimized.
This comment has been minimized.
e687bbe
to
f2a9af4
Compare
Rebased. |
src/NHibernate/Event/Default/DefaultInitializeCollectionEventListener.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: maca88 <[email protected]>
I forgot to re-run the async generator for the last commit, should we create a PR to fix that or do a force push on the last commit in the master? |
Force pushes are not allowed on master. (I could lift the restriction but I would not do it. On patch branches I may allow myself to lift it for dropping more serious mishap.) For merged async regeneration lacks, the handling varies. When it has no impact on the feature (like namespace or test only changes), we tend to just let some later PR fix it with its own async regeneration. When it has an impact on the feature, better do a separate fix. So I have done #2063. |
This PR tends to minimize 2nd level cache calls when retrieving entities/collections from the batchable cache when assembling objects from a cached query. Today, when a cached query is retrieved from the cache the same batching logic is applied as when a lazy entity is initialized, which means that the entity batch fetch size will be used that can be far less that the query result count. To solve this problem a special queue was created that is initialized by the query cache and will replace the current one in order to optimize the cache calls. Once the query cache is done with the assembling the special queue is removed and the old one takes its place.
There is still one optimization that can be done but would require to have the
CacheBatcher
on a sesssion in order to combine multiple entity/collection batch loads when they are not present in the cache. Additionaly a special setting could be added that would allow to batch a bigger number of entities when batching from the database entities that are present in the cached query.This PR should be reviewed after #1952