Add caching at df level
Make sure these boxes are checked before submitting your issue - thank you!
- [x] I have checked the superset logs for python stacktraces and included it here as text if any
- [x] I have reproduced the issue with at least the latest released version of superset
- [x] I have checked the issue tracker for the same issue and I haven't found one similar
Superset version
Master version
Expected results
The caching feature of superset currently is only used in in get_payload which is a function that is called to retrieve the HTTP response sent to the client when they are loading a vizualisation.
get_payload makes a get_df function call and passes the retrieved df to a get_data function which generates the data that is saved in the payload. This data is then cached using whichever caching system is used.
When you are downloading a csv file for a slice from a dashboard, the get_csv function is called which calls get_df, an intermediate function within get_payload.
If we were to cache at a dataframe level, instead of payload level, we can provide caching to more features such as downloading csv files.
I'm raising this issue as it is a common use case at our company. We often have multiple team members downloading the same slice from a shared dashboard, and all of them have to go through the full processing time, which could be improved.
Actual results
To implement caching at a data frame level so that the benefits of caching can be passed down to more features such as downloading slice csv files from dashboards. Any feedback or suggestions?
Steps to reproduce
Yeah, we propose this issue cause we're trying to implement a feature to download all csv files for the whole dashboard as a bundle. And if there's no caching for csv download, it may be quite slow to download all csv in all slices in a dashboard.
We changed the way the cache key is defined recently and CSV may be able to use the cache (would have to be tested & confirmed). The short story is that we used to use the whole set of controls and values to hash the cache_key and that now we only use the input parameters used to make the query.
Hey @mistercrunch,
We changed the way the cache key is defined recently and CSV may be able to use the cache (would have to be tested & confirmed). The short story is that we used to use the whole set of controls and values to hash the cache_key and that now we only use the input parameters used to make the query.
Thank you for the swift response. I took a look at the latest code and I do think that the new caching method would be useful for us to implement said feature.
I am currently thinking of adding a param to the cache to allow us to add determine the layer of data that is cached, e.g. Dataframe level, Payload-data level.
Doing this should enable cache to work with the csv download, while not affecting the other features at the same time. We can reconsider the caching layer for the existing features some other time.
Do you have any other feedback or suggestion for this idea?
I will work on trying to getting the cache to work with csv and will submit a pull request to you guys later.
Related: https://github.com/apache/incubator-superset/pull/4316
Hi @mistercrunch It looks like the changes proposed by @tanhaoqin have not been fully implemented yet. Can you confirm that CSV download still does not use the cache? Is #4316 only build foundation for that?
Really interested in the CSV download use of cache as it appears superset does the query again when the download CSV button is clicked. @tanhaoqin did you pursue your solution?
I just tested the code changes to use cache for csv download, fairly simple and contained to get_csv. I'll look to contribute this.
I submitted #6202 to fix this.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.