X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 45937DA858 for ; Thu, 20 Oct 2005 05:53:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 47348-08 for ; Thu, 20 Oct 2005 08:53:33 +0000 (GMT) Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com [203.22.197.21]) by svr1.postgresql.org (Postfix) with ESMTP id 5FC15DA844 for ; Thu, 20 Oct 2005 05:53:32 -0300 (ADT) Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) by houston.familyhealth.com.au (Postfix) with ESMTP id 7CCBE25076; Thu, 20 Oct 2005 16:53:27 +0800 (WST) Received: from [127.0.0.1] (work-40.internal [192.168.0.40]) by houston.familyhealth.com.au (Postfix) with ESMTP id 5AE642505B; Thu, 20 Oct 2005 16:53:26 +0800 (WST) Message-ID: <43575C5D.3030301@familyhealth.com.au> Date: Thu, 20 Oct 2005 16:59:09 +0800 From: Christopher Kings-Lynne User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Christian Paul B. Cosinas" Cc: pgsql-performance@postgresql.org Subject: Re: Deleting Records References: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147> In-Reply-To: <002701c5d552$5bc7ea30$1e21100a@ghwk02002147> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-familyhealth-MailScanner-Information: Please contact the ISP for more information X-familyhealth-MailScanner: Found to be clean X-familyhealth-MailScanner-From: chriskl@familyhealth.com.au X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.164 required=5 tests=[AWL=-0.093, FORGED_RCVD_HELO=0.05, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200510/280 X-Sequence-Number: 15048 > 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