Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread Richard Huxton
WireSpot wrote: On 10/25/05, Csaba Nagy <[EMAIL PROTECTED]> wrote: I guess your master table has a considerable tree of child records for each deleted record, that's why the deletion takes so long. We have this situation too on top level object deletion. Our solution is to make it asynchronous,

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread WireSpot
On 10/25/05, Csaba Nagy <[EMAIL PROTECTED]> wrote: > I guess your master table has a considerable tree of child records for > each deleted record, that's why the deletion takes so long. We have this > situation too on top level object deletion. Our solution is to make it > asynchronous, i.e. the us

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread Csaba Nagy
I guess your master table has a considerable tree of child records for each deleted record, that's why the deletion takes so long. We have this situation too on top level object deletion. Our solution is to make it asynchronous, i.e. the user requests it and then a background job does it. There's n

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread WireSpot
On 10/25/05, WireSpot <[EMAIL PROTECTED]> wrote: > Thanks for the tip, guys. I'll go punch in some indexes and I'll be > back to report how much of a difference it made. Adding indexes made the dropping of entries for the "master" table roughly 6 (six) times faster. It's definitely an improvement

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread WireSpot
On 10/25/05, Martijn van Oosterhout wrote: > BTW, have you considered TRUNCATE? (although it may not work with > foreign keys). It doesn't :) "TRUNCATE cannot be used if there are foreign-key references to the table from other tables. Checking validity in such cases would require table scans, an

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread Csaba Nagy
On Tue, 2005-10-25 at 11:18, WireSpot wrote: > On 10/25/05, Michael Fuhr <[EMAIL PROTECTED]> wrote: > > Are there indexes on the foreign key columns? That is, given > > the following example, > > > > CREATE TABLE foo (id integer PRIMARY KEY); > > CREATE TABLE bar (fooid integer NOT NULL REFERENCES

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread Martijn van Oosterhout
On Tue, Oct 25, 2005 at 12:18:34PM +0300, WireSpot wrote: > On 10/25/05, Michael Fuhr <[EMAIL PROTECTED]> wrote: > > Are there indexes on the foreign key columns? That is, given > > the following example, > > > > CREATE TABLE foo (id integer PRIMARY KEY); > > CREATE TABLE bar (fooid integer NOT NU

Re: [GENERAL] Deleting vs foreign keys

2005-10-25 Thread WireSpot
On 10/25/05, Michael Fuhr <[EMAIL PROTECTED]> wrote: > Are there indexes on the foreign key columns? That is, given > the following example, > > CREATE TABLE foo (id integer PRIMARY KEY); > CREATE TABLE bar (fooid integer NOT NULL REFERENCES foo ON DELETE CASCADE); > > do you have an index on bar.

Re: [GENERAL] Deleting vs foreign keys

2005-10-24 Thread Michael Fuhr
On Tue, Oct 25, 2005 at 12:59:27AM +0300, WireSpot wrote: > I have an application that makes heavy use of foreign keys all over > the tables. This is very nice since the data is very consistent. There > also this "central" table which holds "sites" in it. A site pretty > much is the crux of it all.

[GENERAL] Deleting vs foreign keys

2005-10-24 Thread WireSpot
I have an application that makes heavy use of foreign keys all over the tables. This is very nice since the data is very consistent. There also this "central" table which holds "sites" in it. A site pretty much is the crux of it all. Deleting a site will very precisely eliminate all data regarding