brianm/jdbi — pull request #96 by matthewbogner (2014-03-30 19:15:21+00:00)
Title: Stop caching inline SQL statments in ClasspathStatementLocator

We've been experiencing an issue in our production environment where 90% of our heap was getting filled up by the ConcurrentMap cache in ClasspathStatementLocator.

I can see the need to cache named SQL statements that cause us to search the classpath, but for inline SQL, I don't see the benefit of caching the string.

There is one performance hit to this, in that every inline SQL statement will get passed through the "looksLikeSQL" method. Personally, I think this is acceptable given the light-weight nature of that method. An alternative implementation (which I'm happy to provide if you don't like the implementation in this pull request), is to use an LRU cache (from Guava) instead of a ConcurrentMap so that the entries can expire after some configurable amount of time.