Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 6C0809FA18C for ; Tue, 5 Dec 2006 11:30:53 -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 16253-07 for ; Tue, 5 Dec 2006 11:30:46 -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 732C29F938C for ; Tue, 5 Dec 2006 11:30:46 -0400 (AST) thread-index: AccYglc5h4iEy6ttQIW/WMkc29qxtg== 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:30:48 -0500 Message-ID: <457590A3.2090006@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:30:43 +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> In-Reply-To: <45758FBF.2030404@aeccom.com> Content-Type: text/plain; format=flowed; charset="ISO-8859-15" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Dec 2006 15:30:49.0078 (UTC) FILETIME=[572DC160:01C71882] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/78 X-Sequence-Number: 22134 Sven Geisler wrote: > I have to refactoring a 'DELETE FROM x WHERE y IN (...)' because IN got > to much parameters. => 'stack depth limit exceeded' > I don't want to increase just the parameter for max_stack_depth. It is > better to refactoring because the number of arguments to IN may increase > in the future. > > My approach is to do multiple 'DELETE FROM x WHERE y=...'. You could also do something in between, issuing the deletes in batches of say 100 deletes each. But using a temporary table is much better. > My question is now, what is better for PostgreSQL from a performance > perspective? > 1. all multiple deletes in one transaction > 2. each delete in its own transaction All in one transaction is definitely faster. > The number of arguments is around 10,000. > > BTW: The arguments are generate in the application tier. I would have to > create a temporary table which I can use in 'DELETE FROM x WHERE y IN > (SELECT z FROM tmp)'. I think that's exactly what you should do. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com