Skip to content

Remove lazy=”false” in NHibernate mappings

December 10, 2012

As I found out, the ASP.NET loading performance is seriously hindered if you set more than one, if several lazy=”false” NHibernate mappings in the hbm.xml files.

Here is the definition of when you set lazy=”false”: –

Subselect fetching – a second SELECT is used to retrieve the associated collections for all entities retrieved in a previous query or fetch. Unless you explicitly disable lazy fetching by specifying lazy="false", this second select will only be executed when you actually access the association.

It slows the performance of the ASP.NET application whenever any page is loaded, NHibernate will pick up all associations stated in the mapping with lazy=”false”, and place this into cache, if you have lots of associations it will load every record in the instance into cache.

Hence why it is very slow, if you remove all of them, you ASP.NET application will load a lot quicker.

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: