Re: optimal insert - Mailing list pgsql-sql

From Markus Schaber
Subject Re: optimal insert
Date
Msg-id 452CE43D.4030806@logix-tt.com
Whole thread Raw
In response to optimal insert  ("Dirk Jagdmann" <jagdmann@gmail.com>)
List pgsql-sql
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 |  1001 |  2001 |   541 | 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


pgsql-sql by date:

Previous
From: "Mark R. Dingee"
Date:
Subject: Re: Temp tables and functions
Next
From: Markus Schaber
Date:
Subject: Re: deleting rows in specific order