Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6C143632AF0 for ; Thu, 15 Jul 2010 21:24:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 66850-07 for ; Fri, 16 Jul 2010 00:24:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 4659563267E for ; Thu, 15 Jul 2010 21:24:50 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o6G0OlFg001006; Thu, 15 Jul 2010 20:24:47 -0400 (EDT) To: "Benjamin Krajmalnik" cc: "Pierre C" , pgsql-performance@postgresql.org Subject: Re: Question of using COPY on a table with triggers In-reply-to: References: Comments: In-reply-to "Benjamin Krajmalnik" message dated "Thu, 15 Jul 2010 17:28:39 -0600" Date: Thu, 15 Jul 2010 20:24:46 -0400 Message-ID: <1005.1279239886@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/251 X-Sequence-Number: 39640 "Benjamin Krajmalnik" writes: > That is what I thought. > The trigger calls a 3000 row stored procedure which does all of the calculations to aggregate data into 3 separate tables and then insert the raw data point into a 4th table. Youch. Seems like you might want to rethink the idea of doing those calculations incrementally for each added row. Wouldn't it be better to add all the new data and then do the aggregation once? regards, tom lane