Re: Best practices for Large import in empty database?

From: Andy Colson <andy(at)squeakycode(dot)net>
To: Daniel Begin <jfd553(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Best practices for Large import in empty database?
Date: 2014-10-01 14:41:14
Message-ID: 542C128A.80905@squeakycode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/1/2014 9:13 AM, Daniel Begin wrote:
> I am about to feed an empty database with a large import of data (the
> size of csv files is about 500 GB). Tables are created but I haven't
> added any constraints or indexes yet. I wonder whether the best practice
> is to add them before or after the import. Are there other good
> practices that would ease the import process?
>
> Cheers,
>
> Daniel
>

create index after, as long as you dont need it for uniqueness checking.

then:

begin;
truncate table junk;
copy ... with freeze;
commit;

Even though the table is empty, the begin,trunc,copy lets PG skip a
bunch of extra WAL.

-Andy

In response to

Browse pgsql-general by date

  From Date Subject
Next Message jlrando 2014-10-01 14:57:40 Postgres tcp_keepalive_xxxx parameters.
Previous Message Tom Lane 2014-10-01 14:37:47 Re: Best practices for Large import in empty database?