Skill 1.4.1
Optimize code to reduce runtime for data ingestion and transformation
Key Concepts
In Spark: filter and select columns early, push predicates to sources, avoid UDFs when built-in functions exist, broadcast small tables in joins, cache reused DataFrames, avoid collect() on large data and tune partition counts. In SQL: avoid SELECT *, use partition filters and appropriate join orders.
In Python/Lambda: reuse clients and connections outside the handler, batch API calls, stream large files rather than loading them fully in memory.