Re: break table into portions for writing to separate files

From: Seb <spluque(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: break table into portions for writing to separate files
Date: 2014-05-01 19:26:41
Message-ID: 874n19pafi.fsf@net82.ceos.umanitoba.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 01 May 2014 21:12:46 +0200,
Torsten Förtsch <torsten(dot)foertsch(at)gmx(dot)net> wrote:

[...]

> # copy (select * from generate_series(1,1000)) to program 'split -l
> 100 - /tmp/xxx'; COPY 1000 # \q

> $ ls -l /tmp/xxxa* -rw------- 1 postgres postgres 292 May 1 19:08
> /tmp/xxxaa -rw------- 1 postgres postgres 400 May 1 19:08 /tmp/xxxab
> -rw------- 1 postgres postgres 400 May 1 19:08 /tmp/xxxac -rw------- 1
> postgres postgres 400 May 1 19:08 /tmp/xxxad -rw------- 1 postgres
> postgres 400 May 1 19:08 /tmp/xxxae -rw------- 1 postgres postgres 400
> May 1 19:08 /tmp/xxxaf -rw------- 1 postgres postgres 400 May 1 19:08
> /tmp/xxxag -rw------- 1 postgres postgres 400 May 1 19:08 /tmp/xxxah
> -rw------- 1 postgres postgres 400 May 1 19:08 /tmp/xxxai -rw------- 1
> postgres postgres 401 May 1 19:08 /tmp/xxxaj

> Each of those contains 100 lines.

Wonderful! I didn't know about this 'PROGRAM' parameter for COPY
nowadays. Although the SELECT is slow, the split will happen very
quickly this way, so this should be acceptable.

Thanks,

--
Seb

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2014-05-01 19:35:17 Re: Ubuntu Packages / Config Files
Previous Message Torsten Förtsch 2014-05-01 19:12:46 Re: break table into portions for writing to separate files