将大量插入Postgres的最快方法是什么? [英] What's the fastest way to do a bulk insert into Postgres?

查看:104
本文介绍了将大量插入Postgres的最快方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式将10百万条记录插入到postgres数据库中.目前,我正在单个查询"中执行1000条插入语句.

I need to programmatically insert 10's of millions of records into a postgres database. Presently I am executing 1000's of insert statements in a single "query".

有一些更好的方法吗,一些我不知道的大容量插入语句?

Is there a better way to do this, some bulk insert statement I dont know about?

推荐答案

PostgreSQL具有最初如何最佳填充数据库的指南,他们建议使用

PostgreSQL has a guide on how to best populate a database initially, and they suggest using the COPY command for bulk loading rows. The guide has some other good tips on how to speed up the process, like removing indexes and foreign keys before loading the data (and adding them back afterwards).

这篇关于将大量插入Postgres的最快方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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