I've been debugging the memory use of our application and I found that in some cases hibernate generated some pretty extensive SQL queries, up to 40KB in length.
These strings go into the query cache as keys and use a lot of memory (potentially). It's also not necessary for the queries to be so big - they're a symptom of mapping errors gone unnoticed that were resulting in really big query strings.
Although I can find these by looking at a heap dump or by turning on query logging on the database and sort of manually scanning for really long lines, I'm wondering if anyone has some ideas on how to automatically detect and log queries over a certain size.
I've tried adding a listener on the ehcache itself, but since all the fields of the hibernate QueryKey are private I have to use toString() to check the length, which would result in some overhead on each use of the cache. Maybe not the worst thing in the world, but...
Does anyone know another good place to hook into this and automatically detect these large queries, or even better detect mappings that will result in over-zealous deep fetches?
|