On Mon, 18 Aug 2008 15:16:01 -0400 Tom Lane <tgl@xxxxxxxxxxxxx> wrote: > Ivan Sergio Borgonovo <mail@xxxxxxxxxxxxxxx> writes: > > I'm not sure what's really happening but why apparently the > > delete statements get executed before the 2 inserts even if > > constraints are deferred? > > You didn't mark the FK constraints as deferrable --- I'm pretty > sure the default is NOT DEFERRABLE. My fault. I don't know how did I succeeded to read that the default was DEFERRABLE while it is clearly stated it is not. I can't see a direct way to add DEFERRABLE to an already existing constraint. Is dropping and adding the only path? > > Why does it take so long? > > Indexes on the FK columns would probably help. There is one actually. I'll post another email with a more sensible subject to ask more advices on this, if google doesn't help me first. Thanks. -- Ivan Sergio Borgonovo http://www.webthatworks.it