Re: Deleting Records

From: Matteo Beccati <php(at)beccati(dot)com>
To: "Christian Paul B(dot) Cosinas" <cpc(at)cybees(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Deleting Records
Date: 2005-10-20 08:52:29
Message-ID: 43575ACD.8000206@beccati.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-10-20 08:57:31 Re: Deleting Records
Previous Message Nörder-Tuitje 2005-10-20 08:50:50 Re: Deleting Records