Table data exclusion patch for pg_dump

Поиск
Список
Период
Сортировка
Искать

Table data exclusion patch for pg_dump

От:
Vadim Trochinsky <me@vadim.ws>
Дата:
Hello!

This is a patch that allows choosing not to dump the data for the selected 
tables.

The intended usage is to make backups smaller and faster, by allowing skipping 
unneeded data, while still generating a backup that can be restored and obtain 
a fully working application.

I use it to avoid dumping log data, and the content of tables that keep data 
that has a short lifetime (which in the event of a restore would have expired 
by then anyway)

The patch adds the -d and -D arguments: -d  --data=TABLE            dump data for the named table(s) -D  --exclude-data=TABLE    do NOT dump data for the named table(s)


I believe the patch to be complete, though I'm very new to the postgresql 
codebase and might have missed something. 

The patch applies to HEAD, compiles and worked properly in my tests.


Re: Table data exclusion patch for pg_dump

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Vadim Trochinsky  writes:
> This is a patch that allows choosing not to dump the data for the selected 
> tables.

Why wouldn't you just use -s ?
		regards, tom lane

Re: Table data exclusion patch for pg_dump

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


Tom Lane wrote:
> Vadim Trochinsky  writes:
>   
>> This is a patch that allows choosing not to dump the data for the selected 
>> tables.
>>     
>
> Why wouldn't you just use -s ?
>
> 			
>   

You might want the whole schema and data for most but not all of the 
tables (e.g. you might leave out a large session table for a web app).

cheers

andrew

Re: Table data exclusion patch for pg_dump

От:
Asko Oja <ascoja@gmail.com>
Дата:
How do you use -s to exclude data for some tables from otherwise full dump?
Dump schema and data separately?

On Fri, May 1, 2009 at 6:38 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Vadim Trochinsky <me@vadim.ws> writes:
> This is a patch that allows choosing not to dump the data for the selected
> tables.

Why wouldn't you just use -s ?

                       regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Re: Table data exclusion patch for pg_dump

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> Tom Lane wrote:
>> Why wouldn't you just use -s ?

> You might want the whole schema and data for most but not all of the 
> tables (e.g. you might leave out a large session table for a web app).

The use-case seems pretty thin to me, and the potential for shooting
oneself in the foot rather large.  We routinely get complaints, for
example, from people who do partial dumps and then find out they don't
restore because of foreign key constraints.  This looks like mostly
a larger-gauge version of that.
		regards, tom lane

Re: Table data exclusion patch for pg_dump

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


Tom Lane wrote:
> Andrew Dunstan  writes:
>   
>> Tom Lane wrote:
>>     
>>> Why wouldn't you just use -s ?
>>>       
>
>   
>> You might want the whole schema and data for most but not all of the 
>> tables (e.g. you might leave out a large session table for a web app).
>>     
>
> The use-case seems pretty thin to me, and the potential for shooting
> oneself in the foot rather large.  We routinely get complaints, for
> example, from people who do partial dumps and then find out they don't
> restore because of foreign key constraints.  This looks like mostly
> a larger-gauge version of that.
>
> 	
>   

Well, you can shoot yourself in the foot using pg_restore's --use-list 
option too, but that doesn't mean it's not useful. And indeed it could 
be used to achieve the OP's ends, except that he would have spent 
useless time and space dumping the data for a table he doesn't want.

cheers

andrew



Re: Table data exclusion patch for pg_dump

От:
Pavel Stehule <pavel.stehule@gmail.com>
Дата:
2009/5/1 Tom Lane :
> Andrew Dunstan  writes:
>> Tom Lane wrote:
>>> Why wouldn't you just use -s ?
>
>> You might want the whole schema and data for most but not all of the
>> tables (e.g. you might leave out a large session table for a web app).
>
> The use-case seems pretty thin to me, and the potential for shooting
> oneself in the foot rather large.  We routinely get complaints, for
> example, from people who do partial dumps and then find out they don't
> restore because of foreign key constraints.  This looks like mostly
> a larger-gauge version of that.

I am sorry, but this use-case is relative maybe often. When we
migrated from 8.1 to 8.3 we truncates all large audit and log tables.
Without this switch we had to use TRUNCATE or own substitution of
pg_dump. I thing so this switch should be implement like TRUNCATE
statement - you have to exclude all depended tables.

regards
Pavel Stehule

>
>                        regards, tom lane
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>

Re: Table data exclusion patch for pg_dump

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Andrew Dunstan  writes:
> Well, you can shoot yourself in the foot using pg_restore's --use-list 
> option too, but that doesn't mean it's not useful. And indeed it could 
> be used to achieve the OP's ends, except that he would have spent 
> useless time and space dumping the data for a table he doesn't want.

The critical difference, of course, being that when he discovers that it
doesn't work, he *has got* the data he needs to have to perform the
restore.  Excluding data at dump time is considerably more dangerous
because of the likelihood that you won't have any recourse when you
need it.

(In which connection, it is an astonishingly bad idea to repurpose -d
and -D for this behavior, so soon after we deprecated them.)
		regards, tom lane

Re: Table data exclusion patch for pg_dump

От:
Jaime Casanova <jcasanov@systemguards.com.ec>
Дата:
On Fri, May 1, 2009 at 2:25 PM, Andrew Dunstan  wrote:
>
>
> Tom Lane wrote:
>>
>> Vadim Trochinsky  writes:
>>
>>> This is a patch that allows choosing not to dump the data for the
>>> selected tables.
>>>
>> Why wouldn't you just use -s ?
>>
>
> You might want the whole schema and data for most but not all of the tables
> (e.g. you might leave out a large session table for a web app).
>

Actually you can use pg_dump -T to exclude some tables and then
pg_dump -s -t to dump the schema of those tables


-- 
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

FAQ