High level Postgres run down of INSERT/UPDATE speed?

可紊 提交于 2019-12-11 05:35:38

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3459969/high-level-postgres-run-down-of-insert-update-speed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!