From: Markus Schaber <schabi@logix-tt.com>
To: Dirk Jagdmann <jagdmann@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: optimal insert
Date: Wed, 11 Oct 2006 14:31:57 +0200
Message-ID: <452CE43D.4030806@logix-tt.com> (raw)
In-Reply-To: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com>
References: <5d0f60990610081404s79a90cdbha4603c70c75ce233@mail.gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: schabi@logix-tt.com, jagdmann@gmail.com
Subject: Re: optimal insert
In-Reply-To: <452CE43D.4030806@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox