Skip to content
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

Support Dynamic BatchFetchStyle #2959

Merged
merged 13 commits into from
Aug 16, 2022
Merged

Conversation

bahusoid
Copy link
Member

@bahusoid bahusoid commented Dec 16, 2021

Fixes #1316
Port of hibernate/hibernate-orm@06b0faa (without Padded fetch style)

To start using Dynamic batch style add the following property to session-factory settings:

<property name="batch_fetch_style">Dynamic</property>

Or configuration by code:

Configuration configuration = ...
configuration.SetProperty(Environment.BatchFetchStyle, BatchFetchStyle.Dynamic.ToString());

Copy link
Member

@hazzik hazzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix formatting issues identified by codefactor and by me.

src/NHibernate.Test/Legacy/FooBarTest.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/NHSpecificTest/GH1920/Fixture.cs Outdated Show resolved Hide resolved
src/NHibernate.Test/NHSpecificTest/NH3142/ChildrenTest.cs Outdated Show resolved Hide resolved
src/NHibernate/Engine/QueryParameters.cs Outdated Show resolved Hide resolved
@bahusoid
Copy link
Member Author

bahusoid commented Dec 16, 2021

Please don't review while it's WIP. It's in working state AFAIK but not polished and no dedicated tests

Assert.That(result.Name, Is.Not.Null);

var childrenCount = result.Children.Count;
//Assert.That(NHibernateUtil.IsInitialized(proxy), Is.True);
Copy link
Member Author

@bahusoid bahusoid Dec 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entity is already loaded by batch loading. But proxy doesn't know about it - NHibernateUtil.IsInitialized(proxy) returns false. Looks like an issue to me (not related to this PR)

@bahusoid bahusoid changed the title WIP Support Dynamic BatchFetchStyle Support Dynamic BatchFetchStyle Dec 17, 2021
@gokhanabatay
Copy link
Contributor

@bahusoid @hazzik
For dynamic batch fetch style works correctly does default_batch_fetch_size needs to be bigger than 1, if it is than is it cause to dublicate queries in memory for those with 2 and 1 parameters.

property in (p0:,p1)
property in (p0)

public virtual IUniqueEntityLoader BuildLoader(IOuterJoinLoadable persister, int batchSize, LockMode lockMode, ISessionFactoryImplementor factory, IDictionary<string, IFilter> enabledFilters)
{
	if (batchSize <= 1)
	{
		// no batching
		return new EntityLoader(persister, lockMode, factory, enabledFilters);
	}

	return BuildBatchingLoader(persister, batchSize, lockMode, factory, enabledFilters);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NH-3530 - memory when using default_batch_fetch_size
4 participants