【问题标题】:Table insert performance bottleneck amazon redshift表插入性能瓶颈亚马逊红移
【发布时间】:2021-02-28 15:20:02
【问题描述】:

在Redhsift表中使用批量插入(https://tool.oschina.net/uploads/apidocs/Spring-3.1.1/org/springframework/jdbc/core/simple/SimpleJdbcInsert.html#executeBatch(org.springframework.jdbc.core.namedparam.SqlParameterSource[]))插入记录时,spring框架会退回到一一插入,需要更多时间。

(main) org.springframework.jdbc.support.JdbcUtils: JDBC driver does not support batch updates

是否可以在 redshift 表中启用批量更新?

如果没有,有没有办法提高redshift中的表插入性能?

我试过 - 将 ?rewriteBatchedStatements=true 添加到 jdbcurl - 仍然一样。

【问题讨论】:

  • 你使用的是官方的 Redshift JDBC 吗?
  • 是的,我使用的是官方的 JDBC。

标签: jdbc amazon-redshift


【解决方案1】:

推荐的批量插入方法是使用复制命令。因此,常见的过程是使用 UNLOAD 命令将数据从 redshift 卸载到 S3(如果要插入的数据来自查询结果),然后运行引用 S3 中数据位置的复制命令。这比插入要有效得多。

UNLOAD ('my SQL statement')
TO 's3::my-s3-target-location'
FORMAT PARQUET;

COPY my_target_table (col1, col2, ...)
FROM 's3::my-s3-target-location'
FORMAT PARQUET;

这是文档:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多