wangyum edited a comment 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("set spark.sql.cbo.enabled=true")
   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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to