Re: Deleting Records - Mailing list pgsql-performance

From Matteo Beccati
Subject Re: Deleting Records
Date
Msg-id 43575ACD.8000206@beccati.com
Whole thread Raw
In response to Deleting Records  ("Christian Paul B. Cosinas" <cpc@cybees.com>)
List pgsql-performance
Hi,

> What could possibly I do so that I can make this fast?
>
> Here is the code inside my function:
>
>     FOR temp_rec IN SELECT * FROM item_qc_doer LOOP
>         DELETE FROM qc_session WHERE item_id = temp_rec.item_id;
>         DELETE FROM item_qc_doer WHERE item_id = temp_rec.item_id;
>     END LOOP;

Qhat about just using:

DELETE FROM gc_session WHERE item_id IN
    (SELECT item_id FROM item_qc_doer)
DELETE FROM item_qc_doer;

It doesn't make sense to run 2 x 22.000 separate delete statements
instead that only two...

And... What about using a foreing key?


Best regards
--
Matteo Beccati
http://phpadsnew.com
http://phppgads.com

pgsql-performance by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Deleting Records
Next
From: Christopher Kings-Lynne
Date:
Subject: Re: Deleting Records