Defer execution using the lazy API to leverage significant performance advantages, as it is preferred in most cases over the eager mode where queries execute immediately. Constructing queries via scan_csv or LazyCsvReader allows the query planner to optimize before collection. This enables predicate pushdown, applying filters early to read only relevant rows, and projection pushdown, selecting only needed columns to avoid loading unused data like petal dimensions. Calling collect triggers evaluation only after all steps are defined. This approach minimizes wasteful intermediate results and reduces memory and CPU load, facilitating faster processing of larger datasets that fit better in memory. Scope: Polars. Reviewed October 4, 2026.
Lazy API versus eager execution
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- docs.pola.rs
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.