Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 813861337BB8 for ; Thu, 2 Dec 2010 04:36:51 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 71514-07 for ; Thu, 2 Dec 2010 08:36:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out.mail.amis.hr (out1.mail.amis.hr [188.129.0.4]) by mail.postgresql.org (Postfix) with ESMTP id D72121335B36 for ; Thu, 2 Dec 2010 04:36:43 -0400 (AST) Received: from out.fsec.sm.srv.amis.hr (out.fsec.sm.srv.amis.hr [192.168.106.22]) by out.mail.amis.hr (Postfix) with ESMTP id 74832201C0; Thu, 2 Dec 2010 09:36:41 +0100 (CET) Received: from pps.filterd (out [127.0.0.1]) by out.fsec.sm.srv.amis.hr (8.14.3/8.14.3) with SMTP id oB28Vd3d005707; Thu, 2 Dec 2010 09:36:41 +0100 Received: from smtp.amis.hr (smtp.sm.srv.amis.hr [192.168.106.39]) by out.fsec.sm.srv.amis.hr with ESMTP id swn6vrqu8-1; Thu, 02 Dec 2010 09:36:41 +0100 A-Original-Client-UID: 188.129.75.173 splivalo Received: from [192.168.10.1] (cpe-188-129-75-173.dynamic.amis.hr [188.129.75.173]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: splivalo) by smtp.amis.hr (Postfix) with ESMTPSA id B743728B; Thu, 2 Dec 2010 09:36:40 +0100 (CET) Message-ID: <4CF75A98.3080709@megafon.hr> Date: Thu, 02 Dec 2010 09:36:40 +0100 From: Mario Splivalo User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Lightning/1.0b1 Thunderbird/3.0.10 MIME-Version: 1.0 To: Pierre C CC: mark.kirkwood@catalyst.net.nz, pgsql-performance@postgresql.org Subject: Re: SELECT INTO large FKyed table is slow References: <4CF24103.8030209@megafon.hr> <4CF3522B.2050203@catalyst.net.nz> <4CF39CF4.2050506@megafon.hr> <4CF587B0.5020003@megafon.hr> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15, 1.0.148, 0.0.0000 definitions=2010-12-02_04:2010-12-02, 2010-12-02, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1010190000 definitions=main-1012020004 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201012/20 X-Sequence-Number: 41472 On 12/01/2010 09:43 AM, Pierre C wrote: > > Note that in both cases postgres reports that the FK checks take 92-120 > milliseconds... which is a normal time for about 4000 rows. > Inserting 4000 lines with just a few fields like you got should take > quite much less than 1 s... > > Where the rest of the time goes, I have no idea. Disk thrashing ? Locks > ? Gremlins ? > > - try it on a fresh copy of all your tables (CREATE TABLE, INSERT INTO > SELECT) > - try to put the WAL on a separate physical disk (or do a check with > fsync=off) > - try it on another computer > - try it on another harddisk > - run oprofile on a debug compile of postgres > - it could even be the process title updates (I don't think so but...) > - try a ramdisk tablespace I'm allready running it with fsync=off. The funny thing is, as I add new realm it runs fine until the history table grows around 5M rows. After that the slowdown is huge. I'm trying this on new hardware this weekend, I'll post here the results. Mario