Re: optimal insert

Поиск
Список
Период
Сортировка
От Markus Schaber
Тема Re: optimal insert
Дата
Msg-id 452CE43D.4030806@logix-tt.com
обсуждение исходный текст
Ответ на optimal insert  ("Dirk Jagdmann" <jagdmann@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: "Mark R. Dingee"
Дата:
Сообщение: Re: Temp tables and functions
Следующее
От: Markus Schaber
Дата:
Сообщение: Re: deleting rows in specific order