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 B0B90DA828 for ; Thu, 20 Oct 2005 05:52:30 -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 45882-08 for ; Thu, 20 Oct 2005 08:52:24 +0000 (GMT) Received: from roast.hq.mobyt.it (194-185-112-82.f5.ngi.it [194.185.112.82]) by svr1.postgresql.org (Postfix) with SMTP id 12A4BDA84F for ; Thu, 20 Oct 2005 05:52:24 -0300 (ADT) Received: (qmail 11544 invoked from network); 20 Oct 2005 10:51:48 +0200 Received: from webdev.hq.mobyt.it (HELO ?10.20.20.4?) (10.20.20.4) by 0 with SMTP; 20 Oct 2005 10:51:48 +0200 Message-ID: <43575ACD.8000206@beccati.com> Date: Thu, 20 Oct 2005 10:52:29 +0200 From: Matteo Beccati User-Agent: Thunderbird 1.4 (Windows/20050908) 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-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.031 required=5 tests=[AWL=-0.019, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/279 X-Sequence-Number: 15047 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