To quote the famous Donald Knuth: “Programmers spend a lot of time thinking about the speed of non-critical parts of their programs or worry about the speed of their non-critical parts, and these attempts at efficiency really have a strong negative impact on debugging and maintenance. We should forget about a little efficiency, say, about 97% of the time: premature optimization is the root of all evil, but we should not miss our opportunity in these critical 3%. "
If you see performance issues, only then can you start optimizing. And you only need to optimize the largest bottleneck and, if necessary, make your way down.
However, implementing this optimization in NHibernate has little impact on debugging and maintenance in most situations and can often be implemented with very minimal code additions.
If you rely heavily on lazy loading, have read-only tables, no need to worry about concurrency applications that do not use NHibernate, performance is a problem, and you are well aware of how to optimize the use of the second level cache (which means you already know the answer to this question), then you should use the second level cache.
source share