First approach: At app startup, I ran a query 'select * from employees' and cached all results (4000 rows). Then, I later access the cache by issuing 'select * from employees' again. The results are put into a map, and I get from the map a subset of the employees (1 to 10).
Second approach: At app startup, I ran queries 'select * from employees where id=#id#' for all id's and cached them (i.e. all employess, 4000 rows). Then, I later access the cache by issuing 'select * from employees where id=#id#' for the employees (1 to 10) that I want. The metrics that I collected suggest that the second approach is a faster way of getting the employees (1 to 10) from the cache. Does this make sense? If so, can someone explain why that is the case? Thanks.
