Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C6EBD9FB391 for ; Wed, 11 Oct 2006 09:32:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 14283-02 for ; Wed, 11 Oct 2006 09:32:06 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 941DF9FB37B for ; Wed, 11 Oct 2006 09:32:05 -0300 (ADT) Received: from kingfisher.intern.logix-tt.com (p549D1B3A.dip0.t-ipconnect.de [84.157.27.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 8F0126599A; Wed, 11 Oct 2006 14:34:28 +0200 (CEST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 420FA18151EB9; Wed, 11 Oct 2006 14:31:58 +0200 (CEST) Message-ID: <452CE43D.4030806@logix-tt.com> Date: Wed, 11 Oct 2006 14:31:57 +0200 From: Markus Schaber Reply-To: pgsql-sql@postgresql.org Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Thunderbird 1.5.0.5 (X11/20060812) MIME-Version: 1.0 To: Dirk Jagdmann Cc: pgsql-sql@postgresql.org Subject: Re: optimal insert References: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com> In-Reply-To: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com> X-Enigmail-Version: 0.94.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.2 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200610/109 X-Sequence-Number: 26498 Hi, Dirk, Dirk Jagdmann wrote: > So for a batch of inserts the value of a stays the same, while for by > arbitrary values are inserted. Now I have wondered if PostreSQL offers > a smarter way to insert those values? A solution can contains usage of > some plpgsql code. [local]:postgres=# insert into a_b (a,b) SELECT 1, (ARRAY[100,200,54,4577])[i] FROM generate_series(1,4) AS i; INSERT 0 4 [local]:postgres=# select * from a_b; a | b ---+------ 1 | 100 1 | 200 1 | 54 1 | 4577 But I tend to agree with others that packing a whole bunch of INSERTs into a single transaction, and using COPY instead will give you better benefits. HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in Europe! www.ffii.org www.nosoftwarepatents.org