snowflakedb / snowflakedb/snowpark-python

Performance Improvement Preview: Duplicate Subquery Elimination

Open
#1,612 0 comments 1 reaction 1 assignee View on GitHub

@sfc-gh-jdu is already working on this.

Since May 16, 2024.

enhancement
Dominant language
Python
Stars
341
Forks
155
Avg merge
4d 16h
Merged PRs (30d)
27

Description

Hi all,

We have an exciting query performance optimization released with Snowpark Python v1.15.0, and we're looking for testing it with production workloads. This optimization will convert duplicate subqueries to CTEs automatically and reduce both query compilation and computation time. We would encourage you to try out this experimental feature if you

  1. use the same Snowpark DataFrame multiple times to build another DataFrame in your workloads, e.g.
df = ...
df1 = df.filter(col("a") == 1)
df2 = df.with_column("c", lit(1))
df3 = df1.join(df2)

OR

  1. previously have manually used df.cache_result() to improve the performance by saving the intermediate result.

Feel free to try this optimization by setting

session.cte_optimization_enabled = True 

at the beginning of code (then no cache_result() is needed), and watch the performance.

If you have any questions, feel free to reach out to me via jianzhun.du@snowflake.com or comment under this issue directly. Any input is appreciated!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.