Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
	SELECT address_id FROM tab2
	UNION ALL
	...
	)
)
?

You could also easily restrict that query to multiple ranges of
adress.ids to control memory usage and transaction duration.



-hannes

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux