From: | Markus Schaber <schabi(at)logix-tt(dot)com> |
---|---|
To: | Dirk Jagdmann <jagdmann(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: optimal insert |
Date: | 2006-10-11 12:31:57 |
Message-ID: | 452CE43D.4030806@logix-tt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Schaber | 2006-10-11 12:48:26 | Re: deleting rows in specific order |
Previous Message | Mark R. Dingee | 2006-10-11 11:02:47 | Re: Temp tables and functions |