james wrote: >Would it be possible to first scan for the ids of things that are >candidates to be deleted (into a temp table) and then subsequently >delete in (modest) batches?
Collecting all ids to be deleted in one temp table is not a good idea to begin with. Collecting the ids could become a scaling problem. The trick is to collect *and* delete in small batches (in the proposed patch I picked 1000 elements per batch; it results in deleting bodyparts in approximately 30 seconds per 1000 parts on my system (PostgreSQL 9.3 HDD based). -- Stephen.
