Re: [GENERAL] Avoid deadlocks on alter table

2016-07-06 Thread Christian Castelli
Hi, by splitting FK contraints, once failed on fk_plan creation while the second time failed on rebuilding public views. I've done a PLPGSQL function that cycles through all schemata and builds views with lots of UNION to join the result. Obviously there are other processes which use these global v

Re: [GENERAL] Avoid deadlocks on alter table

2016-07-06 Thread Christian Castelli
2016-07-05 16:01 GMT+02:00 Adrian Klaver : > > Does the server log have the details, per above? No, it copies just the schema from base_template with a CREATE TABLE x AS base_template.x WITH NO DATA. 2016-07-05 17:24 GMT+02:00 Tom Lane : > I think it'd likely be enough to add the FKs one at a

Re: [GENERAL] Avoid deadlocks on alter table

2016-07-05 Thread Tom Lane
Adrian Klaver writes: > On 07/05/2016 06:30 AM, Christian Castelli wrote: >> ALTER TABLE smartphone >> ADD CONSTRAINT pk_smartphone PRIMARY KEY (id), >> ADD CONSTRAINT fk1 FOREIGN KEY (id_contact) >> REFERENCES contact (id) MATCH SIMPLE >> ON UPDATE RESTRICT ON DELETE RESTRICT, >> ADD CONSTRAINT f

Re: [GENERAL] Avoid deadlocks on alter table

2016-07-05 Thread Adrian Klaver
On 07/05/2016 06:30 AM, Christian Castelli wrote: Hi everybody, my database is composed of multiple schemata, one for each customer, and some global views which do UNION across schemata. I create a new customer with a single transaction, with queries like: CREATE TABLE table1 WITHOUT OIDS AS TAB

[GENERAL] Avoid deadlocks on alter table

2016-07-05 Thread Christian Castelli
Hi everybody, my database is composed of multiple schemata, one for each customer, and some global views which do UNION across schemata. I create a new customer with a single transaction, with queries like: CREATE TABLE table1 WITHOUT OIDS AS TABLE base_template.table1 WITH NO DATA; base_template