JDBC模板批量更新带有雪花数据库非常慢

发布于 2025-01-20 09:31:12 字数 388 浏览 1 评论 0原文

我有一个连接到雪花数据库的Spring Boot应用程序,并上传记录(大约50列不同数据类型)。我正在使用

jdbctemplate.batchupdate(insertsql,value,type)

来执行批量插入。目前,它正在消耗 100 秒数的 50,000记录。我想提高批处理性能。但找不到最佳解决方案。

我提到并尝试了的解决方案T根本有帮助。任何建议都将不胜感激

I have a spring boot application that connects to the Snowflake Database and uploads records (approx 50 columns of different data types). I am using

JdbcTemplate.batchUpdate(insertSql, values, types)

to do the bulk insert. Currently, it is consuming around 100 seconds for 50,000 records. I want to improve the batch performance. but not able to find an optimal solution.

I referred to and tried the solution mentioned in this post, but it didn't help at all. Any suggestions will be highly appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静水深流 2025-01-27 09:31:12

我从批量插入转向 snowflake 复制命令 使用 JDBC。速度快如闪电。使用复制命令,只需 2-3 秒即可从 XS(超小)大小的 Dataware house 的 CSV 文件加载 50000 条记录。

此外,如果出现错误,消息非常清晰,可以在information_schema.load_history中查看。可以加载不同的文件格式,并且有多种选项可以自定义加载过程。

就我而言,我首先将 CSV 文件加载到内部暂存区域(需要不到 1 秒),运行复制命令(需要 1-2 秒),验证 information_schema.load_history 表中的加载状态(需要几毫秒),然后相应地进行

这篇文章也对 使用 JDBC 运行复制命令

I moved away from batch insert to snowflake copy command using JDBC. It is lightning fast. With the copy command, it is barely taking 2-3 seconds to load 50000 records from a CSV file with XS (extra small) size Dataware house.

Moreover, in case of error, messages are very clear and can be viewed in information_schema.load_history. Different file formats can be loaded and there are a variety of options to customize load process.

In my case, I am first loading the CSV file to the internal staging area (takes less than 1 sec), Run Copy command (takes 1-2 seconds), verifying load status in information_schema.load_history table (takes a few milliseconds) and proceed accordingly

This article was also helpful for running copy command with JDBC

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文