Robert Ayrapetyan <robert.ayrapetyan@comodo.com> writes:
> I think it's very easy to check if "table_foo" is empty and therefore
> not requires any locks on
> "parent_table" and generate FK immediately without acquiring the lock
> on "parent" table.
Unfortunately, that's complete nonsense. The reason for the lock on the
parent is so that DDL changes can be applied to it, namely addition of
triggers.
regards, tom lane