I'm not quite sure with what you really want. Do you want to: *a) use a new session for each CreateBar() operation *OR *b) use only a single session for all CreateBar() operations*?
The way I understand it from your sample app, you created only a single session for the whole CreateBar() operations. No wonder it would slow down NH. Not quite sure either why you wanted it that way. IMO, I think it's better to create and use a new session for each CreateBar() operation. Also, have you tried debugging your session creation/disposal logic by outputting session ID using the following line? Console.WriteLine(((SessionImpl) Session).SessionId); That way, you can actually understand how you're actually creating and disposing session. On Fri, Aug 30, 2013 at 3:59 PM, Nicolas Vinot <[email protected]>wrote: > Hello everybody, > > I have a huge problem of performance degradation with NHibernate. > I create a simple demo program, enclosed to this post, which show the > problem. > > I have a simple domain, Foo(long id, string text) and Bar(long id, string > text). > No association between them. > I create a single Foo, then loop X times, fetching the Foo by it text and > create 5000 Bar. > > *On each lap, the fetch of the Foo take more and more time, from 20ms the > first **lap to 1500ms on the 50th or 3000ms on the 100th.* > > 0 Get Foo string -> 00:00:00.1402016 > 10 Get Foo string -> 00:00:00.2103024 > 20 Get Foo string -> 00:00:00.5007200 > 30 Get Foo string -> 00:00:00.8111664 > 40 Get Foo string -> 00:00:01.3419296 > 50 Get Foo string -> 00:00:01.4320592 > 60 Get Foo string -> 00:00:01.5121744 > 70 Get Foo string -> 00:00:01.8726928 > 80 Get Foo string -> 00:00:02.0729808 > 90 Get Foo string -> 00:00:02.7339312 > 100 Get Foo string -> 00:00:03.4149104 > > I search a lot what can cause this problem (query cache, index, flush > session, evict from cache, SQLite and PostgreSQL…), but not success. > On my real application (some associations and more columns), the problem > is worst, with 5000ms on the 10th loop, leading to totally not usable > application with few thousand of data. > I don't remember such a problem on Java Hibernate. > > Can anybody help me to locate the cause of the problem ? > > Thanks in advance ! > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/nhusers. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/groups/opt_out.
