Re: DELETE performance problem - Mailing list pgsql-performance

From Grzegorz Jaśkiewicz
Subject Re: DELETE performance problem
Date
Msg-id 2f4958ff0911250816o55d53c78l2a2940ae0ce0c82c@mail.gmail.com
Whole thread Raw
In response to Re: DELETE performance problem  (Luca Tettamanti <kronos.it@gmail.com>)
List pgsql-performance


On Wed, Nov 25, 2009 at 4:13 PM, Luca Tettamanti <kronos.it@gmail.com> wrote:


DELETE FROM t1 WHERE EXISTS (SELECT 1 FROM t2 WHERE t1.annotation_id = t2.annotation_id)

performs event better:

 Seq Scan on t1  (cost=0.00..170388415.89 rows=22937406 width=6) (actual time=272.625..561241.294 rows=26185953 loops=1)
   Filter: (subplan)
      SubPlan
           ->  Index Scan using t2_idx on t2  (cost=0.00..1113.63 rows=301 width=0) (actual time=0.008..0.008 rows=1 loops=45874812)
                      Index Cond: ($0 = annotation_id)
 Total runtime: 629426.014 ms
(6 rows)

Have you tried:
DELETE FROM t1 USING t2 WHERE  t1.annotation_id = t2.annotation_id;

?




--
GJ

pgsql-performance by date:

Previous
From: Luca Tettamanti
Date:
Subject: Re: DELETE performance problem
Next
From: "Kevin Grittner"
Date:
Subject: Re: Query times change by orders of magnitude as DB ages