Check if key is memoized before doing selects to database.

 Greatly improves performance in case the memoization module is included.