Postgres插入优化

编程入门 行业动态 更新时间:2024-10-26 16:23:05
本文介绍了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插入优化

本文发布于:2023-10-18 12:08:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Postgres

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!