I just added Memcached as my second layer cache for Hibernate. Performance actually took a significant hit after installing the cache. All queries are slower. I realized that the reason is probably due to most of my queries aren't based on id, so second layer cache is not being used.
My question is shouldn't non id-based queries just go straight to the database without ever hitting the cache? Aka, the decision making of whether the query is "cache appropriate" be determined prior to hitting the cache? If so, shouldn't performance be faster?