Question 15
You are given the task of improving the performance of a Spark SQL program. 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 being aggregated, whereas in reality the underlying data has a million values for that key. What actions would you perform from the below to ensure that the right estimates are used?
Create all tables as native Spark SQL tables (i.e. available as CatalogTables).
Partition all tables on the same key on which the aggregate is happening.
Ensure cost based optimizer (CBO) is ON.
Run ANALYZE on all tables.
Cache the table in a step with actions ahead of the SQL statement that is the culprit.