問題文
A Python function scores rows one at a time and is called on 300 million rows. The per-call overhead dominates the runtime. Which change addresses this?
選択肢
- Move the scoring to an external function, because a remote service can process the rows faster than the warehouse.
- Convert it to a stored procedure that loops over the rows, because a loop inside a single call pays the fixed cost only once and therefore removes the per-row overhead completely, no matter how many rows the loop has to visit.
- Increase the warehouse size, because the per-call overhead that the runtime shows on tables of hundreds of millions of rows is a memory constraint that a larger warehouse removes.
- Rewrite it as a function that receives a batch of rows as a dataframe and returns a series of results, so the fixed cost is paid once per batch instead of once per row.