GitHub user dosubot[bot] added a comment to the discussion: Warm up charts cache via API
<!-- Answer --> **No, you don't need to warm up datasets separately.** The [dataset warm_up_cache just iterates through all charts using that dataset and calls chart warm_up_cache for each one](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/dataset/warm_up_cache.py#L44-L53). It's essentially a batch operation that internally does what you're already doing with charts. Your current approach is actually **redundant** — you're warming up the same charts twice: 1. Once via `datasets_service.warm_up_cache(ds)` (which warms all charts using that dataset) 2. Again via `charts_service.warm_up_cache(ch.id, dashboard_id)` **Simplified approach:** ```python def warm_up(self): rel_charts = self.dashboards_service.list_related_charts(self.dashboard.id) [self.charts_service.warm_up_cache(ch.id, self.dashboard.id) for ch in rel_charts] ``` This is sufficient since chart warm_up_cache is the atomic operation that actually executes queries and populates cache. **Regarding the race condition question:** The "Referenced columns not available" error is more likely caused by [cache key mismatch or filter context issues](https://github.com/apache/superset/discussions/34837#discussioncomment-14253126) rather than race conditions between your warm-up calls. The cache key must exactly match what real users will request — if warm_up_cache generates a different query context than actual dashboard usage, the cache won't be hit anyway. For the most reliable cache warming, some users recommend capturing the exact `/api/v1/chart/data` payload from browser DevTools during actual dashboard use and replaying that — it guarantees the cache key matches real requests. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d4138077-c67e-46 ee-a5be-e2e3156797d0?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/d4138077-c67e-46ee-a5be-e2e3156797d0?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge) [](https://cursor.com/link/prompt?text=%2A%2ANo%2C%20you%20don%27t%20need%20to%20warm%20up%20datasets%20separately.%2A%2A%20The%20%5Bdataset%20warm_up_cache%20just%20iterates%20through%20all%20charts%20using%20that%20dataset%20and%20calls%20chart%20warm_up_cache%20for%20each%20one%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/commands/dataset/warm_up_cache.py%23L44-L53%29.%20It%27s%20essentially%20a%20batch%20operation%20that%20internally%20does%20what%20you%27re%20already%20doing%20with%20charts.%0A%0AYour%20current%20approach%20is%20actually%20%2A%2Aredundant%2A%2A%20%E2%80%94%20you%27re%20warming%20up%20the%20same%20charts%20twice%3A%0A1.%20Once%20via%20%60datas ets_service.warm_up_cache%28ds%29%60%20%28which%20warms%20all%20charts%20using%20that%20dataset%29%0A2.%20Again%20via%20%60charts_service.warm_up_cache%28ch.id%2C%20dashboard_id%29%60%0A%0A%2A%2ASimplified%20approach%3A%2A%2A%0A%60%60%60python%0Adef%20warm_up%28self%29%3A%0A%20%20%20%20rel_charts%20%3D%20self.dashboards_service.list_related_charts%28self.dashboard.id%29%0A%20%20%20%20%5Bself.charts_service.warm_up_cache%28ch.id%2C%20self.dashboard.id%29%20for%20ch%20in%20rel_charts%5D%0A%60%60%60%0A%0AThis%20is%20sufficient%20since%20chart%20warm_up_cache%20is%20the%20atomic%20operation%20that%20actually%20executes%20queries%20and%20populates%20cache.%0A%0A%2A%2ARegarding%20the%20race%20condition%20question%3A%2A%2A%20The%20%22Referenced%20columns%20not%20available%22%20error%20is%20more%20likely%20caused%20by%20%5Bcache%20key%20mismatch%20or%20filter%20context%20issues%5D%28https%3A//github.com/apache/superset/discussions/34837%23discussioncomment-14253126%29%20rather%20than%20race %20conditions%20between%20your%20warm-up%20calls.%20The%20cache%20key%20must%20exactly%20match%20what%20real%20users%20will%20request%20%E2%80%94%20if%20warm_up_cache%20generates%20a%20different%20query%20context%20than%20actual%20dashboard%20usage%2C%20the%20cache%20won%27t%20be%20hit%20anyway.%0A%0AFor%20the%20most%20reliable%20cache%20warming%2C%20some%20users%20recommend%20capturing%20the%20exact%20%60/api/v1/chart/data%60%20payload%20from%20browser%20DevTools%20during%20actual%20dashboard%20use%20and%20replaying%20that%20%E2%80%94%20it%20guarantees%20the%20cache%20key%20matches%20real%20requests.) [](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=h ttps%3A//github.com/apache/superset/discussions/38718) GitHub link: https://github.com/apache/superset/discussions/38718#discussioncomment-16260571 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
