diff --git a/docs/src/python/user-guide/lazy/query_plan.py b/docs/src/python/user-guide/lazy/query_plan.py index ac682ec19..f1990d40d 100644 --- a/docs/src/python/user-guide/lazy/query_plan.py +++ b/docs/src/python/user-guide/lazy/query_plan.py @@ -9,6 +9,7 @@ .with_columns(pl.col("name").str.to_uppercase()) .filter(pl.col("comment_karma") > 0) ) +q1.show_graph(optimized=False) # --8<-- [end:plan] # --8<-- [start:createplan] diff --git a/docs/user-guide/lazy/query_plan.md b/docs/user-guide/lazy/query_plan.md index b88ec2784..3dea4ea53 100644 --- a/docs/user-guide/lazy/query_plan.md +++ b/docs/user-guide/lazy/query_plan.md @@ -11,17 +11,16 @@ We can understand both the non-optimized and optimized query plans with visualiz ### Graphviz visualization -First we visualise the non-optimized plan by setting `optimized=False`. - -{{code_block('user-guide/lazy/query_plan','plan',['show_graph'])}} -
```python exec="on" result="text" session="user-guide/lazy/query_plan" --8<-- "python/user-guide/lazy/query_plan.py:setup" ---8<-- "python/user-guide/lazy/query_plan.py:plan" ```
+First we visualise the non-optimized plan by setting `optimized=False`. + +{{code_block('user-guide/lazy/query_plan','plan',['show_graph'])}} + ```python exec="on" session="user-guide/lazy/query_plan" --8<-- "python/user-guide/lazy/query_plan.py:createplan" ``` @@ -36,7 +35,11 @@ The query plan visualisation should be read from bottom to top. In the visualisa We can also print the non-optimized plan with `explain(optimized=False)` -{{code_block('user-guide/lazy/query_plan','plan',['explain'])}} +{{code_block('user-guide/lazy/query_plan','describe',['explain'])}} + +```python exec="on" session="user-guide/lazy/query_plan" +--8<-- "python/user-guide/lazy/query_plan.py:describe" +``` ```text FILTER [(col("comment_karma")) > (0)] FROM WITH_COLUMNS: @@ -82,4 +85,4 @@ The optimized plan is to: - apply the filter on the `comment_karma` column while the CSV is being read line-by-line - transform the `name` column to uppercase -In this case the query optimizer has identified that the `filter` can be applied while the CSV is read from disk rather than writing the whole file to disk and then applying it. This optimization is called *Predicate Pushdown*. \ No newline at end of file +In this case the query optimizer has identified that the `filter` can be applied while the CSV is read from disk rather than reading the whole file into memory and then applying the filter. This optimization is called *Predicate Pushdown*. \ No newline at end of file