Mott Leroy <mott@acadaca.com> writes:
> I'm still confused by the behavior however. The locking behaves as if
> its some kind of *table* level lock, because while the function is
> executing (a long time), a dozen updates and inserts build up waiting
> for some lock to be released. If the loop just occassionally puts a lock
> on a few different rows, I don't see how that could cause the
> experienced behavior -- presumably the lock on those particular rows is
> released after its iteration through the loop. Unless, of course, the
> lock isn't given up ...
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.
regards, tom lane