I have used nhibernate for my implementation. There is a lot of database fetching involved and in order to reduce the processing time I enabled the query caching and loaded full table data on application on start. Then did linq against it. The secondary level caching and the query caching is enabled. It is working but when I do the processing for several times,in my log files I can see queries against cached tables with its primary key and it is doing that for each of the rows in that table. I think its happening because my query is against the full table without any condition. I don't know is this because of any problem in my code or any other issue. When I do it with less number of entities it seems to be working. Does anyone know anything about this issue? Is query caching caches only primary keys of rows?
A:
Query caching will only cache the primary key of the results of the query. From the query cache documentation:
Note that the query cache does not cache the state of any entities in the result set; it caches only identifier values and results of value type. So the query cache should always be used in conjunction with the second-level cache.
iammichael
2010-01-19 18:28:54