Postgres插入优化 [英] Postgres insert optimization

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

问题描述

我有一个脚本,该脚本通过自定义ORM生成数以万计的插入Postgres数据库中。您可以想象,它非常慢。这用于开发目的,以便创建伪数据。我可以在Postgres级别上进行简单的优化以使其更快吗?这是唯一按顺序运行的脚本,并且不需要线程安全。

I have a script that generates tens of thousands of inserts into a postgres db through a custom ORM. As you can imagine, it's quite slow. This is used for development purposes in order to create dummy data. Is there a simple optimization I can do at the Postgres level to make this faster? It's the only script running, sequentially, and requires no thread safety.

也许我可以关闭所有锁定,安全检查,触发器等功能?只是在寻找一种快速有效的解决方案,可以大大加快这一过程。

Perhaps I can turn off all locking, safety checks, triggers, etc? Just looking for a quick and dirty solution that will greatly speed up this process.

谢谢。

推荐答案

如果在生产环境中不需要那种功能,建议您从PostgreSQL配置中关闭fsync。

If you don't need that kind of functionality in production environment, I'd suggest you turn fsync off from your PostgreSQL config. This will speed up the inserts dramatically.

切勿在生产数据库上关闭fsync。

Never turn off fsync on a production database.

这篇关于Postgres插入优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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