gpt4 book ai didi

sql - 在插入查询仍在运行时运行 pg_dump?

转载 作者:行者123 更新时间:2023-11-29 11:48:19 30 4
gpt4 key购买 nike

如果我运行 pg_dump 将表转储到 SQL 文件中,它是否会为表中的最后一行拍摄快照,并将所有行转储到该行?

或者它是否继续转储所有行,甚至那些在运行 pg_dump 之后插入的行?

第二个问题是:在运行 pg_dump 之前停止所有插入查询是个好主意吗?

最佳答案

当您运行 pg_dump 时,它会在您的表上获得一个共享锁。在您运行转储之后完成的任何交易都不会包括在内。因此,当转储完成时,如果当前事务正在处理但尚未提交,它们将不会包含在转储中。

还有一个pg_dump option它可以运行:

--lock-wait-timeout=timeout

Do not wait forever to acquire shared table locks at the beginning ofthe dump. Instead fail if unable to lock a table within the specifiedtimeout. The timeout may be specified in any of the formats acceptedby SET statement_timeout. (Allowed formats vary depending on theserver version you are dumping from, but an integer number ofmilliseconds is accepted by all versions.)

关于sql - 在插入查询仍在运行时运行 pg_dump?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18138053/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com