Created 07-02-2016 01:47 PM
Concerning memory usage and efficiency, when joining two large tables with many columns but only want a few columns from each of them, is it better to select() before or after the join()? My instinct tells me to select() before the join but some other voices would be very helpful
Created 07-02-2016 03:31 PM
Yes. Reducing size of dataset before JOIN would surely help rather than other way round.
Created 07-02-2016 03:31 PM
Yes. Reducing size of dataset before JOIN would surely help rather than other way round.
Created 07-02-2016 05:07 PM
Does this also hold for other methods besides JOIN? E.g., I want to do a groupBy. Should I select() before the groupBy()?
Created 07-03-2016 02:51 AM
Yes. You can think of select() as the "filter" of columns where filter() filters rows. You want to reduce the impact of the shuffle as much as possible. Perform both of these as soon as possible. The groupBy() is going to cause a shuffle by key (most likely). Be careful with the groupBy(). If you can accomplish what you need to do with a reduceBy(), you should use that instead.
If you mean dataframe instead of dataset, SparkSQL will handle much of this optimization for you. But if using normal RDDs, you are going to have to deal with these types of optimizations on your own.
Created 07-04-2016 05:03 AM
Yes. A projection before any sort of transformation/action would help in computation time and storage optimization.