使用Apache Spark 1.6在PostgreSQL 9.6上以批处理模式插入 [英] Insert in batch mode on PostgreSQL 9.6 with Apache Spark 1.6

查看:98
本文介绍了使用Apache Spark 1.6在PostgreSQL 9.6上以批处理模式插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请执行以下操作:

dataFrame.write.mode(saveMode).jdbc(url, "tablename", new java.util.Properties())

命令是使用Apache Spark 1.6 Scala编写的

Command is written in Scala, Apache Spark 1.6

这需要一个DataFrame并将数据一行一行地插入PostgreSQL中.我们需要以批处理方式执行此操作.

That takes a DataFrame and inserts data in PostgreSQL row by row, one by one. We need to do this in batch mode.

任何人都知道是否存在任何配置或完成此配置的另一种方法?

Anyone knows if exists any configuration or another way to accomplish that?

预先感谢

推荐答案

根据文档-链接-您可以使用batchsize参数批量执行插入操作

According to documentation - link - you can use batchsize parameter to perform inserts in batches

dataFrame
    .write
    .mode(saveMode)
    .option("batchsize", 1000)
    .jdbc(url, "tablename", new java.util.Properties())

现在插入的文件将按1000行进行批量处理

Now insert will be perfomed in batches of 1000 rows

这篇关于使用Apache Spark 1.6在PostgreSQL 9.6上以批处理模式插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆