I have two methods: RenderFormats() and RenderInsurProducts().
The first method obtains some data from DB using simple query: "select from Format f order by f.Name". After the data is loaded and presented, the RenderInsurProducts() method is invoked.
The second method does similar thing using similar query.
The problem is long time of execution of second method. It takes about 5 seconds to obtain the data using ISession.
During execution of the second query, NHibernate is getting property values of entities loaded in the first query. It looks like NHibernate is looking for cached entities. Probably, this is the reason of slow query execution.
I used SQL Server Profiler to watch time of query execution. During debugging RenderInsurProducts() method I noticed, that when the query was displayed in the Profiler, the rendering starts immediately, but it has taken a few seconds before the query displayed in the Profiler.
When I swap these methods, the execution of both methods is fast.
Im using NHibernate v1.2.1 with SQL Server 2005.
|