[GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Daniel Migowski
Hi, I face the following problem: I have a large table with 12 million addresses, referenced by 20 other tables (some containing about one million entries). There are indexes on the foreign keys. Now I wanted to delete about 10 million addresses (that are not referenced anymore from

Re: [GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Chris Angelico
On Tue, Dec 20, 2011 at 3:01 AM, Daniel Migowski dmigow...@ikoffice.de wrote: DELETE FROM address WHERE id NOT IN (SELECT address_id FROM bank where address_id IS NOT NULL)    AND id NOT IN (SELECT poboxaddress_id FROM bank where poboxaddress_id IS NOT NULL)    AND id NOT IN (SELECT

Re: [GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Pavel Stehule
Hello 2011/12/19 Daniel Migowski dmigow...@ikoffice.de: Hi, I face the following problem: I have a large table with 12 million addresses, referenced by 20 other tables (some containing about one million entries). There are indexes on the foreign keys. Now I wanted to delete about 10

Re: [GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Marti Raudsepp
On Mon, Dec 19, 2011 at 18:14, Pavel Stehule pavel.steh...@gmail.com wrote: you can disable check per session if you need ALTER TABLE ... DISABLE TRIGGER ALL; This is NOT a per-session command, this applies to all connections and queries, and may allow incorrect data into the table. Don't do

Re: [GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Pavel Stehule
2011/12/19 Marti Raudsepp ma...@juffo.org: On Mon, Dec 19, 2011 at 18:14, Pavel Stehule pavel.steh...@gmail.com wrote: you can disable check per session if you need ALTER TABLE ... DISABLE TRIGGER ALL; This is NOT a per-session command, this applies to all connections and queries, and may

Re: [GENERAL] Feature Request: Better handling of foreign keys in DELETE statements

2011-12-19 Thread Hannes Erven
Hi Daniel, Now I wanted to delete about 10 million addresses (that are not referenced anymore from anywhere), and have a statement like: What about: DELETE FROM address WHERE id IN ( SELECT id FROM address EXCEPT ( SELECT address_id FROM tab1 UNION ALL