Not sure if this solution is much better. We don't keep keypool keys in memory (only a 64bit identifier), therefore a DB operation is required. Another solution would be to do a in-mem cache of the oldest key.
This solution, at least, does not retain and release the key.