Dbo: LRU prepared statement cache
We currently have a prepared statement cache for every database connection. We do a string-based lookup to see if we already have a prepared statement in the cache, and otherwise we add a new prepared statement.
If we have more uses of the same prepared statement we add extra copies to the cache.
We however don't ever remove prepared statements from the cache, except for completely emptying the cache on a reconnect. This means that we may keep accruing prepared statements, especially if string concatenation is used to create queries (which we of course don't want to do, we want to bind parameters, but sometimes it may not be avoidable). This may cause us to waste memory on the database server side as well.
We could consider adding a configurable maximum of prepared statements, and discard those that were least recently used.
No data to display