pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
To: Christian Paul B. Cosinas <cpc@cybees.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Deleting Records
Date: Thu, 20 Oct 2005 16:59:09 +0800
Message-ID: <43575C5D.3030301@familyhealth.com.au> (raw)
In-Reply-To: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147>
References: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147>

> 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




view thread (6+ messages)

Message-ID: <43575C5D.3030301@familyhealth.com.au>
Permalink:  ../43575C5D.3030301@familyhealth.com.au/
Also on:    postgresql.org/message-id/43575C5D.3030301@familyhealth.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: chriskl@familyhealth.com.au, cpc@cybees.com
  Subject: Re: Deleting Records
  In-Reply-To: <43575C5D.3030301@familyhealth.com.au>
  References: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147> <43575C5D.3030301@familyhealth.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox