【发布时间】:2020-10-07 19:03:10
【问题描述】:
我第二次运行查询时速度明显更快。为什么?
代码:
publicvoidtest3() {
Dataset<Row>SQLDF=spark.read().json(path:"src/main/resources/data/ipl.json");
SQLDF.repartition(2);
Dataset<Row>result1=SqlDF.where("run>10000").select(col:"team",...cols:"run");
//Dataset<Row>cachedPartition=result1.cache();
result.collect();
//result1.show();log.info("PhysicalPlan\n"+result1.queryExecution().executedPlan());
Dataset<Row>result2=SqlDF.where("run>10000").select(col:"team",..cols:"run");
result2.collect();
//result1.show();
Log.info("PhysicalPlan\n"+result2.queryExecution().executedPlanq);
}
物理计划:
spark UI 上的执行时间:
为什么这些查询需要不同的时间,为什么执行时间有如此大的差异?缓存是否发生在幕后?如果是,为什么物理计划中没有提到?
【问题讨论】:
-
请不要发布您的屏幕照片。代表性数据和代码应在您的帖子中以文本形式提供。您的问题是为什么第二次运行查询会更快?
标签: apache-spark pyspark apache-spark-sql