Thanks to everybody who made suggestions. There was the legitimate constraint violation caused by a bug in an importing program. Program was erroneously inserting zero integer into the field that is both the leading part of the primary key (possibly causing its non-uniqueness), and a foreign key (definitely causing its violation). This triggered the slowdown behavior. I can't understand why exactly, because the primary key should have failed immediately, and the foreign key was deferred. But that's what happened.
Yuri