Re: large numbers of inserts out of memory strategy

Поиск
Список
Период
Сортировка
Искать
От
Steven Lembark
Тема
Re: large numbers of inserts out of memory strategy
Дата
Msg-id
20171201114942.177b394c@wrkhors.com
Ответ на
Список
Дерево обсуждения
large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy Steven Lembark <lembark@wrkhors.com>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy Rob Sargent <robjsargent@gmail.com>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy Steven Lembark <lembark@wrkhors.com>
Re: large numbers of inserts out of memory strategy Rob Sargent <robjsargent@gmail.com>
Re: large numbers of inserts out of memory strategy Rory Campbell-Lange <rory@campbell-lange.net>
Re: large numbers of inserts out of memory strategy Tomas Vondra <tomas.vondra@2ndquadrant.com>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy Steven Lembark <lembark@wrkhors.com>
Re: large numbers of inserts out of memory strategy Tomas Vondra <tomas.vondra@2ndquadrant.com>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy Tomas Vondra <tomas.vondra@2ndquadrant.com>
Re: large numbers of inserts out of memory strategy Brian Crowell <brian@fluggo.com>
Re: large numbers of inserts out of memory strategy Tom Lane <tgl@sss.pgh.pa.us>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: large numbers of inserts out of memory strategy Christopher Browne <cbbrowne@gmail.com>
Re: large numbers of inserts out of memory strategy Christopher Browne <cbbrowne@gmail.com>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: large numbers of inserts out of memory strategy Ted Toth <txtoth@gmail.com>
Re: large numbers of inserts out of memory strategy "Peter J. Holzer" <hjp-pgsql@hjp.at>
Re: large numbers of inserts out of memory strategy Steven Lembark <lembark@wrkhors.com>
Re: large numbers of inserts out of memory strategy Tom Lane <tgl@sss.pgh.pa.us>
On Thu, 30 Nov 2017 08:43:32 -0600
Ted Toth  wrote:

> What is the downside of using a DO block? I'd have to do a nextval on
> each sequence before I could use currval, right? Or I could do 'select
> last_value from '.

You are creating a piece of code that has to be parsed, tokenized,
and compiled prior to execution. What's biting you is that you've
created a function the size of your dataset.

If you like do-blocks then write a short block to insert one record
using placeholders and call it a few zillion times.

That or (in DBI-speak):


    eval
    {
        $dbh->{ RaiseError  } = 1;
        $dbh->{ AutoCommit  } = 0;

        my $sth = $dbh->prepare
        (
            'insert into yourtable ( field field ) values ( $1, $2 )'
        );

        $sth->do( @$_ ) for @rows;

        $dbh->commit
    }
    or die "Failed execution: $@";

which will be nearly as effecient in the long run.

That or just import the data from a csv/tsv (there are good 
examples of data import available in the PG docs).

-- 
Steven Lembark                                       1505 National Ave
Workhorse Computing                                 Rockford, IL 61103
lembark@wrkhors.com                                    +1 888 359 3508

В списке pgsql-general по дате отправления
От: Ted Toth
Дата:
От: support-tiger
Дата:
Сообщение: pg data backup from vps
FAQ