From: Rob Sargent <robjsargent@gmail.com>
To: Ted Toth <txtoth@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: large numbers of inserts out of memory strategy
Date: Tue, 28 Nov 2017 10:55:54 -0700
Message-ID: <5570090c-885b-73ad-529d-f217fd197b2b@gmail.com> (raw)
In-Reply-To: <CAFPpqQGxt7oij-HF1S23uEQHZ=fAngsbe28TvXJQkijKMwwZhw@mail.gmail.com>
References: <CAFPpqQGux3uT=CNN-z=zXr4qSmfBw9tDCURimELqEWUBrBpL7A@mail.gmail.com>
<74C96E30-97C3-45D1-887F-F876602355DE@gmail.com>
<CAFPpqQGxt7oij-HF1S23uEQHZ=fAngsbe28TvXJQkijKMwwZhw@mail.gmail.com>
On 11/28/2017 10:50 AM, Ted Toth wrote:
> On Tue, Nov 28, 2017 at 11:19 AM, Rob Sargent <robjsargent@gmail.com> wrote:
>>> On Nov 28, 2017, at 10:17 AM, Ted Toth <txtoth@gmail.com> wrote:
>>>
>>> I'm writing a migration utility to move data from non-rdbms data
>>> source to a postgres db. Currently I'm generating SQL INSERT
>>> statements involving 6 related tables for each 'thing'. With 100k or
>>> more 'things' to migrate I'm generating a lot of statements and when I
>>> try to import using psql postgres fails with 'out of memory' when
>>> running on a Linux VM with 4G of memory. If I break into smaller
>>> chunks say ~50K statements then thde import succeeds. I can change my
>>> migration utility to generate multiple files each with a limited
>>> number of INSERTs to get around this issue but maybe there's
>>> another/better way?
>>>
>>> Ted
>>>
>> what tools / languages ate you using?
> I'm using python to read binary source files and create the text files
> contains the SQL. Them I'm running psql -f <file containing SQL>.
If you're going out to the file system, I would use COPY of csv files
(if number of records per table is non-trivial). Any bulk loading
python available?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com, txtoth@gmail.com
Subject: Re: large numbers of inserts out of memory strategy
In-Reply-To: <5570090c-885b-73ad-529d-f217fd197b2b@gmail.com>
References: <CAFPpqQGux3uT=CNN-z=zXr4qSmfBw9tDCURimELqEWUBrBpL7A@mail.gmail.com> <74C96E30-97C3-45D1-887F-F876602355DE@gmail.com> <CAFPpqQGxt7oij-HF1S23uEQHZ=fAngsbe28TvXJQkijKMwwZhw@mail.gmail.com> <5570090c-885b-73ad-529d-f217fd197b2b@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox