Re: [GENERAL] Optimization of FK creation

2010-10-08 Thread Tom Lane
Robert Ayrapetyan 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 paren

[GENERAL] Optimization of FK creation

2010-10-08 Thread Robert Ayrapetyan
Hello. It's often neccessary to create empty table and FK to some existing table from this newly created table. However, even newly created (empty) table requires lock on parent table it wants refer to. On large production DBs with high load on parent table it's almost neverending operation. For