| From: | Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au> |
|---|---|
| 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:59:09 |
| Message-ID: | 43575C5D.3030301@familyhealth.com.au |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-performance |
> 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;
>
> Item_qc_oder table contains 22,000 records.
Also, chekc you have an index on both those item_id columns.
Also, why don't you just not use the loop and do this instead:
DELETE FROM qc_session WHERE item_id IN (SELECT item_id FROM item_qc_doer);
DELETE FROM item_qc_doer;
Chris
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Steinar H. Gunderson | 2005-10-20 10:16:34 | Re: Materializing a sequential scan |
| Previous Message | Christopher Kings-Lynne | 2005-10-20 08:57:31 | Re: Deleting Records |