高级 Postgres 的 INSERT/UPDATE 速度下降?
我知道当我更新 Pg 中的一行时,该行会被重写,并且当新行被激活时旧行会被停用。我知道这是由于 MVCC 层的实现方式造成的。
那么 UPDATE
相对于 DELETE ... INSERT
的优势是什么?关于Postgresql中UPDATE
和DELETE
的关系还有什么要说的吗?我找不到任何谈论这个或邮件列表帖子的文档。显然,他们运行不同的用户触发器(如果有的话),但幕后发生了什么才能给他们不同的性能配置文件?
I know that when I UPDATE
a row in Pg, that row gets rewritten and the old row gets deactivated when the new row gets activated. I know this is due to how the MVCC layer is implemented.
What the advantages then of UPDATE
over DELETE ... INSERT
? Is there anything else to be said about the relationship of UPDATE
and DELETE
in Postgresql? I can't find any docs that speak of this or mailing list postings.. Obviously, they run different user triggers if any but what happens under the hood to give them different performance profiles?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DELETE 将触发外键约束,您可能会违反它们。其他触发因素也可能是一个问题。
如果您更改 FILLFACTOR,您还为数据库提供了执行热更新的选项。这是在与原始记录所在的同一内存块内进行的更新。与正常更新相比,热更新可以更快,并且产生的开销(真空)要少得多。
A DELETE will trigger foreign key constraints, you could violate them. Other triggers might be a problem as well.
If you change the FILLFACTOR, you also give the database the option to do a HOT update. That's an update inside the same memory block as where the original record is located. HOT updates can be much faster and generate a lot less overhead (vacuum) as a normal update.