"F.B. ten Kate" <[email protected]> writes:

[session vs. stateless session]
> Well wouldn't NHibernate be slow _every_ time i run this query then?

Not necessarily. I don't know the exact overhead, but the default,
stateful session uses caching mechanisms, so maybe filling the cache
is slow.

I would also suspect, as NHibernate tends to be lazy, that quite some
of the internal overhead of initializing everything is delayed until
you really do something.

Another observation I made is that my project which uses NHibernate
runs about a order of magnitude slower when run from inside Visual
Studio. Directly running the compile exe without VS is much faster
(log4net with my logging config and NHibernates intensive logging is
my current best candidate for these slowdowns, but I never really
investigated this because for me it doesn't matter).

> After all it has no problems doing so the 2nd time i click the
> button. Also afaik EF also has to create these objects.

Does EF have a session cache (by default)?

I'd also agree with Fabio that it's quite pointless to micro benchmark
a complex beast like a ORM with toy examples, when these tools are
usually pay off only in quite complex scenarios and applications. If
top querying performance of mass data is your primary goal, never use
any kind of ORM, neither NHibernate nor EF.

> I'm willing to give the stateless session a try though, how would i
> implement that?

Instead of opening a new session with factory.OpenSession() use
factory.OpenStatelessSession(). Everything else may be left
unchanged. BTW have a look at

http://www.nhforge.org/doc/nh/en/index.html

-- 
Until the next mail...,
Stefan.

Attachment: pgp8kzll15dPv.pgp
Description: PGP signature

Reply via email to