Question 16
You are given the task of improving the performance of a Spark SQL program that is doing a simple count after a series of transformations. You suspect that the culprit is the main transformation job in the program. When you run EXPLAIN on that SQL, you see that Spark wrongly estimates that there are only 10 values for the key on which the main transformation job is hinged upon, whereas in reality the underlying data has a million values for that key. What actions would you perform from the below to increase the estimation accuracy?
Create all tables as external tables.
Ensure cost based optimizer (CBO) is ON.
Partition all tables on the same key on which the aggregate is happening.
Run ANALYZE on all tables to ensure the right estimates are available to theoptimizer.
Cache the table in a step with actions ahead of the SQL statement that is theculprit.