Tom Lane wrote:
No, the locks would be held till end of transaction. It is a little odd that you have so many conflicts, though, unless the referenced table is pretty small and/or this loop manages to touch a large fraction of the possible keys.
Ah, well, if the locks are held to the end of the transaction that would explain it I think. I mean, the loop touches *every* row (UPDATEs) in one of the tables. It sounds like I need to break up this function into a smaller function (by placing the loop outside the transaction).