Detect the amount of `CACHE` SQL queries
Following the discussion in:
I consider the CACHE SELECT * FROM
to not be free, but rather be
a memory-intensive operation.
The cached queries help with reducing DB load, but they still:
- consume memory
- require as to re-instantiate each AR object
- require as to re-instantiate each relation of the object
- makes us spend additional CPU-cycles to look into a list of cached queries.
We should treat the CACHE
the same as N+1
queries. They are cheaper,
but they are not cheap at all from ~memory perspective.
We need a way to detect the number of DB cached calls in the scope of the request and in the scope of the sidekiq worker.
Edited by Nikola Milojevic