gpt4 book ai didi

apache-spark - Spark 到 MySQL 的 JDBC 写入速度低

转载 作者:行者123 更新时间:2023-12-03 07:47:37 24 4
gpt4 key购买 nike

我需要从 Spark DataFrame 向 MySQL 写入大约 100 万行,但插入速度太慢。我该如何改进它?

代码如下:

df = sqlContext.createDataFrame(rdd, schema)
df.write.jdbc(url='xx', table='xx', mode='overwrite')

最佳答案

答案在 https://stackoverflow.com/a/10617768/3318517对我有用。将 rewriteBatchedStatements=true 添加到连接 URL。 (参见Configuration Properties for Connector/J。)

我的基准测试从 3325 秒缩短到 42 秒!

关于apache-spark - Spark 到 MySQL 的 JDBC 写入速度低,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36912442/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com