"Ed L." <pgsql(at)bluepolka(dot)net> writes:
> I think I'm seeing table-level lock contention in the following function
I think you're barking up the wrong tree entirely. There's nothing in
that function that would acquire a conflicting table lock.
I'm wondering about foreign key lock contention, myself. Look to what
the DELETE must do.
regards, tom lane