Re: Is there a way to selective dump of records in Postgres 9.0.3? - Mailing list pgsql-performance

From Samuel Gendler
Subject Re: Is there a way to selective dump of records in Postgres 9.0.3?
Date
Msg-id BANLkTi=tEWyfam8WUpnMPN58S+5rXS-WsA@mail.gmail.com
Whole thread Raw
In response to Re: Is there a way to selective dump of records in Postgres 9.0.3?  (Nikolas Everett <nik9000@gmail.com>)
List pgsql-performance


On Mon, Apr 18, 2011 at 8:11 AM, Nikolas Everett <nik9000@gmail.com> wrote:
This probably isn't the right place to ask that question but you may as well try `pg_dump -t PATTERN`.  Man pg_dump for more information on how to form that pattern.


On Mon, Apr 18, 2011 at 11:05 AM, Sethu Prasad <sethuprasad.in@gmail.com> wrote:
Hi List,
I am using PostgreSQL 9.0.3 and I have a need to dump only the selective data from partial list of tables of a database. Is there a straight way to do it with pg_dump or any alternative work around to suggest here?!

Or if you need partial data from one table - a WHERE clause - then you can do:
 
COPY (select * from whatever where column=value) TO '/tmp/dump.csv' WITH CSV HEADER 

in combination with 

pg_dump -f whatever.sql -s -t whatever db

to dump the DDL for the 'whatever' table into whatever.sql.


If it is a lot of data, you'll want to edit the whatever.sql file to remove the CREATE INDEX statements until after you've loaded the table and then depeneding upon how many indexes there are and how many rows you havem you may want to parallelize the CREATE INDEX statements by running them in parallel in multiple psql sessions (and possibly with an artificially large maintenance_work_mem if that speeds things up)

pgsql-performance by date:

Previous
From: tv@fuzzy.cz
Date:
Subject: Re: REINDEX takes half a day (and still not complete!)
Next
From: Robert Haas
Date:
Subject: Re: Index use difference betweer LIKE, LIKE ANY?