|
From: NHibernate J. <mik...@us...> - 2007-03-05 08:26:37
|
[ http://jira.nhibernate.org/browse/NH-859?page=comments#action_15200 ] Ken Tong commented on NH-859: ----------------------------- >From Almas' example, only 1 call to Loader.CreateSubselects(). But it ends up creating 1000 SubselectFetch instances. Digging deeper to the source code find out the 1000 instances are identical. In fact, there is only 1 sub-select in the generated SQL SELECT. Would we create only 1 SubselectFetch? How about replace /////////////////////////////////////////////////// foreach (EntityKey[] rowKeys in keys) { for (int i = 0; i < rowKeys.Length; i++) { if (rowKeys[i] != null && loadables[i].HasSubselectLoadableCollections) { SubselectFetch subselectFetch = new SubselectFetch( //getSQLString(), aliases[i], loadables[i], queryParameters, keySets[i], namedParameterLocMap ); session.BatchFetchQueue.AddSubselect(rowKeys[i], subselectFetch); } } } /////////////////////////////////////////////////// with /////////////////////////////////////////////////// SubselectFetch[] subselectFetchCache = new SubselectFetch[loadables.Length]; foreach (EntityKey[] rowKeys in keys) { for (int i = 0; i < rowKeys.Length; i++) { if (rowKeys[i] != null && loadables[i].HasSubselectLoadableCollections) { SubselectFetch subselectFetch = subselectFetchCache[i]; if (subselectFetch == null) { subselectFetch = new SubselectFetch( //getSQLString(), aliases[i], loadables[i], queryParameters, keySets[i], namedParameterLocMap ); subselectFetchCache[i] = subselectFetch; } session.BatchFetchQueue.AddSubselect(rowKeys[i], subselectFetch); } } } /////////////////////////////////////////////////// It's only an idea. I tried the current unit tests and they don't smell bad. > Improve SubselectFetch performance > ---------------------------------- > > Key: NH-859 > URL: http://jira.nhibernate.org/browse/NH-859 > Project: NHibernate > Type: Patch > Components: Core > Versions: 1.2.0.Beta3 > Reporter: Sergey Koshcheyev > Priority: Trivial > Fix For: 1.2.0.CR1 > Attachments: NH-859 CompareInfo.diff, NH-859.diff > > http://forum.hibernate.org/viewtopic.php?p=2336860#2336860 > SubselectFetch constructor takes a relatively long time to execute. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.nhibernate.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |