Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A070110AC4D3 for ; Sat, 7 Jan 2012 10:19:19 -0400 (AST) Received: from mail.erwied.eu ([85.214.80.157]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RjX77-0006b2-BZ for pgsql-performance@postgresql.org; Sat, 07 Jan 2012 14:19:18 +0000 Received: from dslb-188-109-228-054.pools.arcor-ip.net ([188.109.228.54] helo=erwied.dyndns.org ident=nobody) by mail.erwied.eu with esmtpsa (Exim 4.76#1) id 1RjX6V-0008LB-CY ; Sat, 07 Jan 2012 15:18:39 +0100 Received: from joe-lifebook.dhcp.erwied.de ([172.17.10.70] helo=localhost) by erwied.dyndns.org with esmtpsa (Exim 4.77#2) id 1RjX6U-0002rP-8y ; Sat, 07 Jan 2012 15:18:38 +0100 Date: Sat, 7 Jan 2012 15:18:37 +0100 From: Jochen Erwied Organization: Creative Chaos Computing X-Priority: 3 (Normal) Message-ID: <1723406361.20120107151837@erwied.eu> To: "Marc Mamin" CC: antoine@inaps.org, pgsql-performance@postgresql.org Subject: Re: Duplicate deletion optimizations In-Reply-To: References: <3da8ce0cdf1da4ef873841d01ed0e70a@inaps.org> <3907c59005bc154cf0b8ebb918303d51@inaps.org> <1301943199.20120107125726@erwied.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201201/26 X-Sequence-Number: 46039 Saturday, January 7, 2012, 1:21:02 PM you wrote: > where t_imp.id is null and test.id=t_imp.id; > => > where t_imp.id is not null and test.id=t_imp.id; You're right, overlooked that one. But the increase to execute the query is - maybe not completely - suprisingly minimal. Because the query updating the id-column of t_imp fetches all rows from test to be updated, they are already cached, and the second query is run completely from cache. I suppose you will get a severe performance hit when the table cannot be cached... I ran the loop again, after 30 minutes I'm at about 3-5 seconds per loop, as long as the server isn't doing something else. Under load it's at about 10-20 seconds, with a ratio of 40% updates, 60% inserts. > and a partial index on matching rows might help (should be tested): > (after the first updat) > create index t_imp_ix on t_imp(t_value,t_record,output_id) where t_imp.id is not null. I don't think this will help much since t_imp is scanned sequentially anyway, so creating an index is just unneeded overhead. -- Jochen Erwied | home: jochen@erwied.eu +49-208-38800-18, FAX: -19 Sauerbruchstr. 17 | work: joe@mbs-software.de +49-2151-7294-24, FAX: -50 D-45470 Muelheim | mobile: jochen.erwied@vodafone.de +49-173-5404164