【发布时间】:2017-12-31 09:24:54
【问题描述】:
在read committed 隔离级别中,同一事务中的两个后续选择查询可能会产生不同的结果,因为这两个查询之间可能存在并发更新:
transaction 1: select id from table;
=> returns [1, 2, 3]
transaction 2: delete from table where id = 2;
transaction 1: select id from table;
=> returns [1, 3]
如果事务 1 中的选择查询合并到 CTE 中会发生什么?假设我有以下虚拟查询:
with
cte_1 as (select id from table),
cte_2 as (select id from table)
select (select count(*) from cte_1, select count(*) from cte_2)
如果在cte_1 和cte_2 的执行之间发生并发更新,现在是否也有可能得到不同的结果?
【问题讨论】:
标签: sql postgresql