Hi
In my system I do a centralized calculation on an aggregate with a lot of collections. I need ALL of the collections to be loaded before the calculation, and therefore I use a multicriteria that joins the collections on the root.
The criteria i listed here below. It takes approx 500ms to run on my local setup, and that is a lot of wait for the user. Does anybody have any ideas of how I could optimize this? Any help that can make this query faster is appreciated!
(I have changed the names of the collections for a little privacy :))
IMultiCriteria criteria = session.CreateMultiCriteria()
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ACollection", JoinType.LeftOuterJoin)
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("BCollection", JoinType.LeftOuterJoin)
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("CCollection", JoinType.LeftOuterJoin)
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ECollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("FCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("GCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("HCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("JCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("KCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("LCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("MCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("NCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("OCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("PCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("QCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("RCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("SCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("TCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("UCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("VCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("WCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("XCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("YCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ZCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("AACollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ABCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ACCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("ADCollection", JoinType.LeftOuterJoin))
.Add(DetachedCriteria.For<Building>()
.Add(Restrictions.Eq("Id", BuildingId))
.CreateCriteria("AECollection", JoinType.LeftOuterJoin));