Thanks for the update. Actually I was able to rewrite the query to get rid of the union. But anyway it would be good to have this issue handled somehow, it's tricky and it was hard to spot and reproduce.
ср, 8 січ. 2025 р. о 19:01 Tom Lane <tgl@xxxxxxxxxxxxx> пише:
I wrote:
> Andrey <adnyre@xxxxxxxxx> writes:
>> ... but I would expect to get the same result as previously. Is it a bug
>> or am I doing something wrong here?
> It's a surprising result for sure, but I believe it's explained by
> the algorithm for READ COMMITTED [1], specifically the bit about
Actually, on further thought I believe this really is a bug,
because if you change the UNION ALL to UNION it works fine.
It probably used to work with UNION ALL too, but that was a few
decades ago before we started adding optimizations of UNION ALL :-(
I've been poking at this off and on for the last few days, and I've
found three different things that will need to be changed to make
it work again. At least one of them looks too invasive to consider
for back-patch. So don't hold your breath for a proper fix, but
perhaps you could use UNION as a workaround?
regards, tom lane