we would then want the dashboard to cache all day. However, my concern is that setting the caching threshold very low (e.g. 0 seconds) and TTL to make everything last all day - would cause every query to be cached. And I don’t know what effect that would have on the application.
Has anyone else tried this method? Has anyone else had this issue? how have you gone about solving it?
@theo I haven’t dug into it, just going by memory, but the dashboard filters applied to the cards, which are essentially questions, so the TTL for those questions (in report_card table) is what define the TTL, but again I haven’t tested.
When you make a query through the API (or whatever you are doing to pre-cache everything), then you should see all the results show in the query_cache table.
But you would have to make sure that each filter option is visited, so it stores a cache of that.
@flamber thanks for your help on this one. Although just looking at the report_card table it seems all the values for cache_ttl are NULL.
After manually changing this to 100 as a test - on one 5-second question. The question is still not cached. Have you got an insight on whats going on here?
@theo Correct. All of them are null by default, since that means it will use the global TTL.
But is cache enabled globally? Check your logs, which should tell you how and when caching is handled.
I suppose I was thinking that if I set cache_ttl to not null then the query would cache regardless of query time. (if it didn’t exceed the minimum duration).
However, that seems not to be the case. Changing the field cache_ttl does cause it to cache for that length of time. But it won’t cache in the first place unless it exceeds the minimum duration.
@flamber have you got any suggestions for how to cause a card to cache, regardless of query time?
@theo Manually generate the query_cache entries, then you’ll have the control you’re looking for. What you’re specifically asking for isn’t part of Metabase yet, as you can see from the issues I have referenced.
Thanks @flamber I appreciate this is not something thats a part of Metabase. Just trying to look for a work around that will help us and maybe some others, without having to change the application code in anyway.
But manually generating the query_cache, would involve hashing the results and I’m not sure how to do that in a way that metabase could read. That doesn’t sound straight forward, and a fair bit of work to have to define the queries in a script, read the results hash them and then insert into metabase db.
One VERY hacky way that I think would work. is simply to put a sleep statement in the questions I want to cache, that is longer than the minimum duration to trigger caching.
And just manually change their TTLs so they last all day.
Hi @theo, I am new to metabase but having a similar problem with massive dashboards that we want to cache once a day automatically. Can you please give me a hint on how you constructed these functions?