You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/01/11 03:36:48 UTC
[GitHub] [spark] wangyum commented on pull request #31024: [SPARK-33979][SQL] Reorder predicate
wangyum commented on pull request #31024:
URL: https://github.com/apache/spark/pull/31024#issuecomment-757607737
```scala
spark.range(20000).selectExpr("id as a", "id as b", "id as c").write.saveAsTable("t1")
spark.sql("ANALYZE TABLE t1 COMPUTE STATISTICS FOR ALL COLUMNS")
spark.sql(s"SELECT * FROM t1 WHERE (a > 10 and b > 10000) or (c < 10 and b < 10000)").explain("cost")
```
My change result:
```
== Optimized Logical Plan ==
Filter (((b#3193L > 10000) AND (a#3192L > 10)) OR ((c#3194L < 10) AND (b#3193L < 10000))), Statistics(sizeInBytes=312.4 KiB, rowCount=1.00E+4)
+- Relation[a#3192L,b#3193L,c#3194L] parquet, Statistics(sizeInBytes=625.0 KiB, rowCount=2.00E+4)
```
@tanelk's change result:
```
== Optimized Logical Plan ==
Filter (((a#3192L > 10) AND (b#3193L > 10000)) OR ((c#3194L < 10) AND (b#3193L < 10000))), Statistics(sizeInBytes=312.4 KiB, rowCount=1.00E+4)
+- Relation[a#3192L,b#3193L,c#3194L] parquet, Statistics(sizeInBytes=625.0 KiB, rowCount=2.00E+4)
```
It seems my change is better.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org