NHibernate second level cache for collections is slow

I want to store reference data in a second level cache. I found that for queries that return a single object, this is actually faster, but when the query returns a collection, the cache is much slower than the database access.

I know NHibernate does a lot of work of collecting entities from key / value pairs while grabbing them from the cache, but I still wonder how much slower it is.

Let's say my use case is to populate the dropdown with all available languages, it looks like NHibernate caching doesn't help at all. Is this typical? Does anyone do something like this with better results than me?

As a comparison, storing such a collection directly in NCache is about 400 times faster than NHibernate caching (with NCache) delivers.

Excerpt from NHProf;

- statement # 1 Load cache level 2 Language (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 2 Loading the cache of the second level Language.CurrentLocalizations (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 3 Load L2 cache LanguageLocalization (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 4 Load cache level 2 Language (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 5 Loading the second level cache Language.CurrentLocalizations (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 6 Load L2 cache LanguageLocalization (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

- statement # 7 Load cache level 2 Language (Hrware.Foundation.Infrastructure.Persistence.Temporal.TemporalIdentifier / * id * /)

...

etc.

+3


source to share





All Articles