Right now I includes up to 6 realtions in my query, to avoid n+1 queries. Building up this Object tree takes a lot of the time. Sometimes more that querying the data and processing the jbuilder. How about we only do it, if the cache is empty for this object.
I would imagine something like!
- Get only fields to generate cache_key from db like
id, updated_at without building the object tree
- Get data from cache
- Get remaining data where cache was missed from database and process block for them, return cache for the others
What do you think?
Right now I
includesup to 6 realtions in my query, to avoidn+1queries. Building up this Object tree takes a lot of the time. Sometimes more that querying the data and processing the jbuilder. How about we only do it, if the cache is empty for this object.I would imagine something like!
id,updated_atwithout building the object treeWhat do you think?