3 weeks ago
Dear team,
I'm investigate to improve performance when reading large csv file as input and find this https://learn.microsoft.com/en-us/azure/databricks/optimizations/disk-cache.
I just wonder Do disk-cache also apply for csv file?
Thanks!
3 weeks ago
The answer is "yes but".
If you read a csv into a dataframe, and apply a cache action, no matter what file format, it will be cached (if spark can read it of course).
That being said: spark applies lazy evaluation. So this means the csv is only actually read when an action is executed (like write, count, ...). Before that Spark will only generate a query plan.
So to speed up your code, it is important to find out what the best location is to apply the cache. Because caching is an expensive operation (it actually writes the data to disk) and it will only come in handy if the cached dataframe is used more than once afterwards.
Not sure if that makes sense?
3 weeks ago
The answer is "yes but".
If you read a csv into a dataframe, and apply a cache action, no matter what file format, it will be cached (if spark can read it of course).
That being said: spark applies lazy evaluation. So this means the csv is only actually read when an action is executed (like write, count, ...). Before that Spark will only generate a query plan.
So to speed up your code, it is important to find out what the best location is to apply the cache. Because caching is an expensive operation (it actually writes the data to disk) and it will only come in handy if the cached dataframe is used more than once afterwards.
Not sure if that makes sense?
3 weeks ago
To add on that: Disk cache (formerly detla cache/dbio cache) automates some things, but the principle remains:
you will only gain if the cached df is used multiple times.
3 weeks ago
Thanks @-werners-,
That's right, I tried and get some significantly performance.
Excited to expand your horizons with us? Click here to Register and begin your journey to success!
Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!