Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1FF6B1337B5A for ; Tue, 30 Nov 2010 20:51:44 -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 33566-06 for ; Wed, 1 Dec 2010 00:51:38 +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 76BAB1337B4F for ; Tue, 30 Nov 2010 20:51:36 -0400 (AST) Received: (qmail 3476 invoked by uid 503); 1 Dec 2010 00:27:27 -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 00:27:26 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 1 Dec 2010 02:51:36 +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 02:51:34 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Mladen Gogala" , "Mario Splivalo" Cc: "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> Date: Wed, 01 Dec 2010 01:51:33 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: <4CF59017.1090705@megafon.hr> User-Agent: Opera Mail/10.62 (Linux) X-Ovh-Tracer-Id: 11246895645811869210 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: 201011/423 X-Sequence-Number: 41447 > Now I tried removing the constraints from the history table (including > the PK) and the inserts were fast. After few 'rounds' of inserts I added > constraints back, and several round after that were fast again. But then > all the same. Insert of some 11k rows took 4 seconds (with all > constraints) and now the last one of only 4k rows took one minute. I did > vacuum after each insert. > > > Mario Hm, so for each line of drones_history you insert, you also update the correspoding drones table to reflect the latest data, right ? How many times is the same row in "drones" updated ? ie, if you insert N rows in drones_nistory, how may drone_id's do you have ?