如果使用异步提交将数据插入postgresql数据库,那么后续的select查询是否能够保证将其读取的数据写入磁盘?
我将生成的数据存储在postgresql中,由于数据可以重新生成,所以我想利用异步提交来增加整个过程。但是,生成的数据定期与外部系统同步,并且重要的是,已经发送到外部系统的数据不会丢失。
发布于 2018-04-01 13:44:22
让同步程序在某个虚拟表中更新计数器或时间戳,并提交更新:
begin;
select * from async_inserted;
-- maybe do something in the external system here
update dummy set synctime=now();
commit;
-- or maybe do something external here instead当然,如果更新或提交失败,仍然可能使您不知道外部系统应该处于什么状态。您可能需要使用准备好的事务(也称为"2阶段提交“)将这两个系统原子地结合在一起。
https://dba.stackexchange.com/questions/202778
复制相似问题