Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 950829F9C9E for ; Tue, 5 Dec 2006 11:43:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 18630-10 for ; Tue, 5 Dec 2006 11:42:59 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id CF3EC9F938C for ; Tue, 5 Dec 2006 11:42:59 -0400 (AST) thread-index: AccYhAyJg3ioH/LAQ4aVUDuucFUB0g== Received: from [192.168.1.34] ([82.12.224.9]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.1830); Tue, 5 Dec 2006 10:43:02 -0500 Message-ID: <45759381.40909@enterprisedb.com> Content-Class: urn:content-classes:message Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2757 Date: Tue, 05 Dec 2006 15:42:57 +0000 From: "Heikki Linnakangas" User-Agent: Thunderbird 1.5.0.7 (X11/20060927) MIME-Version: 1.0 To: "Sven Geisler" Cc: Subject: Re: single transaction vs multiple transactions References: <45758FBF.2030404@aeccom.com> <457590A3.2090006@enterprisedb.com> <457591B7.80408@aeccom.com> In-Reply-To: <457591B7.80408@aeccom.com> Content-Type: text/plain; format=flowed; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Dec 2006 15:43:02.0796 (UTC) FILETIME=[0C823CC0:01C71884] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/80 X-Sequence-Number: 22136 Sven Geisler wrote: > I have to insert my arguments to a temporary table first, because the > arguments are only known in the application tier. > Is a multiple insert to a temporary table and a final 'DELETE FROM x > WHERE y IN (SELECT z FROM tmp)' faster than multiple deletes? If the number of records is high, it most likely is faster. You should try it with your data to be sure, but in general doing all the deletes in one batch is faster when the number of records is high because it allows using efficient merge joins or sequential scans. Populating the temporary table with no indexes should be quite inexpensive if you make sure you don't do it one record at a time. Use the COPY command or batched inserts instead. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com