Apache spark 中断SQL查询以提高Spark效率
我有一个非常大的配置单元SQL查询,要迁移到sparkApache spark 中断SQL查询以提高Spark效率,apache-spark,apache-spark-sql,Apache Spark,Apache Spark Sql,我有一个非常大的配置单元SQL查询,要迁移到spark 分割查询是否可以节省性能 合并: Dataset<Row> sqlDF = spark.sql("select c.name from order o join customer c on o.orderID=c.orderID where o.productPrice > 100"); Dataset sqlDF=spark.sql(“从订单中选择c.name,然后在o.orderID=c.orderID上加入客户c,
分割查询是否可以节省性能 合并:
Dataset<Row> sqlDF = spark.sql("select c.name from order o join customer c on o.orderID=c.orderID where o.productPrice > 100");
Dataset sqlDF=spark.sql(“从订单中选择c.name,然后在o.orderID=c.orderID上加入客户c,其中o.productPrice>100”);
与之相比:
Dataset<Row> order = spark.sql("select o.orderID from order where where o.productPrice > 100");
Dataset<Row> customer= spark.sql("select c.orderID, c.name from customer);
Dataset<Row> joinedTable = order.join(customer, customer("orderID"));
Dataset order=spark.sql(“从订单中选择o.orderID,其中o.productPrice>100”);
数据集customer=spark.sql(“从customer中选择c.orderID、c.name”);
Dataset joinedTable=order.join(客户,客户(“orderID”);
使用数据帧会降低可读性,但我不确定spark如何优化请求。如果未完成的查询也表现出性能不足,那么答案是肯定的 我见过Spark SQL使用70个表连接,但由于内存错误而失败。通过缓存将其分解为更小的集合,可以随后执行所有操作 Catalyst正在变得更好,但在传统RDBMS的最佳优化器方面落后于imho。它或其继任者将迎头赶上 同样的问题也适用于Oracle
我认为您的示例不会显示出任何优势,但有时需要拆分更复杂的查询,但这是根据具体情况进行的。您可以将spark生成的代码与spark生成的代码进行比较,看看其中一个是否比另一个有任何额外的优化。答案是有好处的吗?实际上,我知道它是如此。。。