Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 697A31337B9E for ; Wed, 1 Dec 2010 04:23:32 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 16167-09 for ; Wed, 1 Dec 2010 08:23:25 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by mail.postgresql.org (Postfix) with SMTP id A56391337B84 for ; Wed, 1 Dec 2010 04:23:24 -0400 (AST) Received: (qmail 19602 invoked by uid 503); 1 Dec 2010 07:59:13 -0000 Received: from b9.ovh.net (HELO mail632.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 1 Dec 2010 07:59:13 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 1 Dec 2010 10:23:24 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 1 Dec 2010 10:23:23 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Mario Splivalo" Cc: "Mladen Gogala" , "pgsql-performance@postgresql.org" Subject: Re: SELECT INTO large FKyed table is slow References: <4CF24103.8030209@megafon.hr> <4CF5259C.8000306@vmsinfo.com> <4CF59017.1090705@megafon.hr> <4CF5FEA9.3000900@megafon.hr> Date: Wed, 01 Dec 2010 09:23:23 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: <4CF5FEA9.3000900@megafon.hr> User-Agent: Opera Mail/10.62 (Linux) X-Ovh-Tracer-Id: 430938191207335542 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N 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, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201012/4 X-Sequence-Number: 41456 > Just once. OK, another potential problem eliminated, it gets strange... > If I have 5000 lines in CSV file (that I load into 'temporary' table > using COPY) i can be sure that drone_id there is PK. That is because CSV > file contains measurements from all the drones, one measurement per > drone. I usualy have around 100 new drones, so I insert those to drones > and to drones_history. Then I first insert into drones_history and then > update those rows in drones. Should I try doing the other way around? No, it doesn't really matter. > Although, I think I'm having some disk-related problems because when > inserting to the tables my IO troughput is pretty low. For instance, > when I drop constraints and then recreate them that takes around 15-30 > seconds (on a 25M rows table) - disk io is steady, around 60 MB/s in > read and write. > > It just could be that the ext3 partition is so fragmented. I'll try > later this week on a new set of disks and ext4 filesystem to see how it > goes. If you CLUSTER a table, it is entirely rebuilt so if your disk free space isn't heavily fragmented, you can hope the table and indexes will get allocated in a nice contiguous segment.