I know caching is most commonly used to prevent repeated execution of expensive queries. However, in our application, we have a couple of scenarios where we very frequently (say, hundreds of times per second) execute queries that are, theoretically, rather inexpensive. For example,
SELECT push_token FROM devices WHERE id = ?
or
SELECT value FROM some_table_with_configs WHERE key = ?
My question is whether it is worth to cache the results of these rather inexpensive queries, or if I'm better off hitting the DB (PostgreSQL, in case it matters) everytime and let the RDBMS's caches do their work?
In case it matters, I'm using JDBC with proper connection pooling and that those queries return results that change very, very infrequently.