Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Bill Moran
On Mon, 01 Dec 2014 11:00:51 -0600 Andy Colson wrote: > On 12/1/2014 10:21 AM, Giuseppe Sacco wrote: > > Il giorno lun, 01/12/2014 alle 09.49 -0600, Andy Colson ha scritto: > >> On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: > >>> Hello, > >>> I have a main table and a lot of "details" tables that r

Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Andy Colson
On 12/1/2014 10:37 AM, Alban Hertroys wrote: On 1 December 2014 at 17:21, Giuseppe Sacco wrote: Il giorno lun, 01/12/2014 alle 09.49 -0600, Andy Colson ha scritto: On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: 2) Try inheritance. I have no idea if it'll help, but I thought I'd read someplace

Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Andy Colson
On 12/1/2014 10:21 AM, Giuseppe Sacco wrote: Il giorno lun, 01/12/2014 alle 09.49 -0600, Andy Colson ha scritto: On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: Hello, I have a main table and a lot of "details" tables that reference the main one. Every time I delete a record from the main table, a

Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Alban Hertroys
On 1 December 2014 at 17:21, Giuseppe Sacco wrote: > Il giorno lun, 01/12/2014 alle 09.49 -0600, Andy Colson ha scritto: >> On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: >> 2) Try inheritance. I have no idea if it'll help, but I thought I'd >> read someplace where the planner knew a little more ab

Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Giuseppe Sacco
Il giorno lun, 01/12/2014 alle 09.49 -0600, Andy Colson ha scritto: > On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: > > Hello, > > I have a main table and a lot of "details" tables that reference the > > main one. > > > > Every time I delete a record from the main table, a check is done on > > every

Re: [GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Andy Colson
On 12/1/2014 9:23 AM, Giuseppe Sacco wrote: Hello, I have a main table and a lot of "details" tables that reference the main one. Every time I delete a record from the main table, a check is done on every details table that contain a foreign key toward main table. This is a simplified schema:

[GENERAL] Slow delete when many foreign tables are defined

2014-12-01 Thread Giuseppe Sacco
Hello, I have a main table and a lot of "details" tables that reference the main one. Every time I delete a record from the main table, a check is done on every details table that contain a foreign key toward main table. This is a simplified schema: create table main ( type varchar, serial numer

Re: [GENERAL] Slow delete with with cascading foreign keys

2008-10-20 Thread Tom Lane
Matthias Karlsson <[EMAIL PROTECTED]> writes: > Tom Lane skrev: >> If it's a reasonably modern PG version, EXPLAIN ANALYZE will break out >> the time spent in each on-delete trigger, which should be enough to >> answer the question. > Thanks, that gave me something to work with. I targeted the tri

Re: [GENERAL] Slow delete with with cascading foreign keys

2008-10-20 Thread Matthias Karlsson
Tom Lane skrev: "Matthias Karlsson" <[EMAIL PROTECTED]> writes: I have a rather complex set of relations, connected with cascading foreign keys on delete. I'm experiencing very slow performance when deleting *the* lead node, which everything eventually depends on. The number of records ultimatel

Re: [GENERAL] Slow delete with with cascading foreign keys

2008-10-20 Thread Tom Lane
"Matthias Karlsson" <[EMAIL PROTECTED]> writes: > I have a rather complex set of relations, connected with cascading > foreign keys on delete. I'm experiencing very slow performance when > deleting *the* lead node, which everything eventually depends on. The > number of records ultimately to be del

[GENERAL] Slow delete with with cascading foreign keys

2008-10-20 Thread Matthias Karlsson
Hi, I have a rather complex set of relations, connected with cascading foreign keys on delete. I'm experiencing very slow performance when deleting *the* lead node, which everything eventually depends on. The number of records ultimately to be deleted aren't that many (perhaps 2000-3000) but there

Re: [GENERAL] Slow delete

2005-07-13 Thread Tom Lane
Doug Hall <[EMAIL PROTECTED]> writes: >> If the EXPLAIN output doesn't say >> anything about a "hashed subplan", then either you've got an old >> version or there's some sort of estimation problem. > No, the EXPLAIN doesn't mention "hashed subplan". I suspect it was a > bug in the beta. You mig

Re: [GENERAL] Slow delete

2005-07-13 Thread Doug Hall
On Jul 13, 2005, at 12:46 PM, Tom Lane wrote: Doug Hall <[EMAIL PROTECTED]> writes: delete from citizen where id not in (select citizenid from citizen_stage); The explain select tells me that there is a sequential select of citizen_stage records. (??) There are 75009 citizen records and 1477

Re: [GENERAL] Slow delete

2005-07-13 Thread Tom Lane
Doug Hall <[EMAIL PROTECTED]> writes: > delete from citizen where id not in (select citizenid from > citizen_stage); > The explain select tells me that there is a sequential select of > citizen_stage records. (??) There are 75009 citizen records and 14778 > records, and it's taking more than ha

[GENERAL] Slow delete

2005-07-13 Thread Doug Hall
Sorry. I realize this is a rather newbie question, but I've got a slow delete going on here, and I could use some help figuring out why. This is the classic "get rid of orphans" select. delete from citizen where id not in (select citizenid from citizen_stage); citizen.id and citizen_stage.ci