Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 08E799FB439 for ; Mon, 9 Oct 2006 00:58:49 -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 36027-09 for ; Mon, 9 Oct 2006 00:58:45 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from wolff.to (wolff.to [66.93.197.194]) by postgresql.org (Postfix) with SMTP id 6E47B9FB3E2 for ; Mon, 9 Oct 2006 00:58:45 -0300 (ADT) Received: (qmail 21538 invoked by uid 500); 9 Oct 2006 04:09:24 -0000 Date: Sun, 8 Oct 2006 23:09:24 -0500 From: Bruno Wolff III To: Dirk Jagdmann Cc: pgsql-sql@postgresql.org Subject: Re: optimal insert Message-ID: <20061009040924.GA20636@wolff.to> Mail-Followup-To: Bruno Wolff III , Dirk Jagdmann , pgsql-sql@postgresql.org References: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/90 X-Sequence-Number: 26479 On Sun, Oct 08, 2006 at 23:04:02 +0200, Dirk Jagdmann wrote: > > insert into a_b(a,b) values(1,100); > insert into a_b(a,b) values(1,200); > insert into a_b(a,b) values(1,54); > insert into a_b(a,b) values(1,4577); > > 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. I don't think you are going to be able to save anything by 'a' being fixed unless there is a way to compute 'b', so that you can use a select statement. Just do the normal stuff you would when speeding up inserts. The biggest probably being wrapping them all up in one transaction.