Re: inserting multiple values in version 8.1.5

Поиск
Список
Период
Сортировка
От Jonathan Vanasco
Тема Re: inserting multiple values in version 8.1.5
Дата
Msg-id 67305190-0C51-4B9B-9693-CCCA836CE303@2xlp.com
обсуждение исходный текст
Ответ на Re: inserting multiple values in version 8.1.5  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
On Apr 3, 2007, at 10:33 AM, A. Kretschmer wrote:

> am  Tue, dem 03.04.2007, um  7:19:15 -0700 mailte rkmr.em@gmail.com
> folgendes:
>> I need to do like 1000 inserts periodically from a web app. Is it
>> better to do
>> 1000 inserts or 1 insert with the all 1000 rows? Is using copy
>> command faster
>> than inserts?
>
> You can do the massive Inserts within one transaktion, but COPY is
> much
> faster than many Inserts. The multi-line Insert is a new feature since
> 8.2. I prefer COPY.

not all database drivers support copy ,  so that might not be
applicable.

I know the  perl DBD::Pg does,  but I haven't seen it in many other
languages.

you could try doing all the inserts in 1 transaction in a loop using
a prepared statement.  that should give you a bit of a speedup.

ie (in bastardized perl/python):
    $db->begin
    $prepared_statement= """INSERT INTO x (a,b) VALUES ( :id , :name );"""
    for row in update_loop:
        $prepared_statement->execute( row['id'] , row['name']
    $db->commit






// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -



В списке pgsql-general по дате отправления:

Предыдущее
От: "pobox@verysmall.org"
Дата:
Сообщение: Re: use superuser connection from php
Следующее
От: "marcel.beutner"
Дата:
Сообщение: newid() in postgres