Thread: inconvenient compression options in pg_basebackup

inconvenient compression options in pg_basebackup

From
Peter Eisentraut
Date:
There is no way to tell pg_basebackup to "just compress the thing in a
default way".  You have to pick some number and then write -Z8 or
something.  I suppose that interface was copied from pg_dump, but there
it's not that commonly used because the right formats are compressed by
default.

I suggest we add an argument-less option -z that means "compress", and
then -Z can be relegated to choosing the compression level.



Re: inconvenient compression options in pg_basebackup

From
Magnus Hagander
Date:
On Thu, May 19, 2011 at 17:56, Peter Eisentraut <peter_e@gmx.net> wrote:
> There is no way to tell pg_basebackup to "just compress the thing in a
> default way".  You have to pick some number and then write -Z8 or
> something.  I suppose that interface was copied from pg_dump, but there
> it's not that commonly used because the right formats are compressed by
> default.

It was copied from pg_dump, yes.


> I suggest we add an argument-less option -z that means "compress", and
> then -Z can be relegated to choosing the compression level.

We can't just use -Z without a parameter for that?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


Re: inconvenient compression options in pg_basebackup

From
Peter Eisentraut
Date:
On fre, 2011-05-20 at 14:19 -0400, Magnus Hagander wrote:
> > I suggest we add an argument-less option -z that means "compress",
> and
> > then -Z can be relegated to choosing the compression level.
> 
> We can't just use -Z without a parameter for that? 

You can't portably have a command-line option with an optional argument.



Re: inconvenient compression options in pg_basebackup

From
Magnus Hagander
Date:
On Fri, May 20, 2011 at 17:45, Peter Eisentraut <peter_e@gmx.net> wrote:
> On fre, 2011-05-20 at 14:19 -0400, Magnus Hagander wrote:
>> > I suggest we add an argument-less option -z that means "compress",
>> and
>> > then -Z can be relegated to choosing the compression level.
>>
>> We can't just use -Z without a parameter for that?
>
> You can't portably have a command-line option with an optional argument.

Ugh.

In that case, I'm fine with your suggestion.


--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


Re: inconvenient compression options in pg_basebackup

From
Peter Eisentraut
Date:
On sön, 2011-05-22 at 16:43 -0400, Magnus Hagander wrote:
> On Fri, May 20, 2011 at 17:45, Peter Eisentraut <peter_e@gmx.net> wrote:
> > On fre, 2011-05-20 at 14:19 -0400, Magnus Hagander wrote:
> >> > I suggest we add an argument-less option -z that means "compress",
> >> and
> >> > then -Z can be relegated to choosing the compression level.
> >>
> >> We can't just use -Z without a parameter for that?
> >
> > You can't portably have a command-line option with an optional argument.
>
> Ugh.
>
> In that case, I'm fine with your suggestion.

Quick patch for verification.  I chose the naming -z/--gzip to mirror
GNU tar.

Attachment

Re: inconvenient compression options in pg_basebackup

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> Quick patch for verification.  I chose the naming -z/--gzip to mirror
> GNU tar.

I would argue that -Z ought to turn on "gzip" without my having to write
-z as well (at least when the argument is greater than zero; possibly
-Z0 should be allowed as meaning "no compression").

Other than that (and the ensuing docs and help changes), looks fine.
        regards, tom lane


Re: inconvenient compression options in pg_basebackup

From
Peter Eisentraut
Date:
On tis, 2011-05-24 at 15:34 -0400, Tom Lane wrote:
> I would argue that -Z ought to turn on "gzip" without my having to
> write
> -z as well (at least when the argument is greater than zero; possibly
> -Z0 should be allowed as meaning "no compression"). 

My concern with that is that if we ever add another compression method,
would we then add another option to control the compression level of
that method?



Re: inconvenient compression options in pg_basebackup

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> On tis, 2011-05-24 at 15:34 -0400, Tom Lane wrote:
>> I would argue that -Z ought to turn on "gzip" without my having to write
>> -z as well (at least when the argument is greater than zero; possibly
>> -Z0 should be allowed as meaning "no compression"). 

> My concern with that is that if we ever add another compression method,
> would we then add another option to control the compression level of
> that method?

Um ... what's your point?  Forcing the user to type two switches instead
of one isn't going to make that hypothetical future extension any
easier, AFAICS.

But if you want to take such an extension into account right now, maybe
we ought to design that feature now.  What are you seeing it as looking
like?

My thought is that "-z" should just mean "give me compression; a good
default compression setting is fine".  "-Zn" could mean "I want gzip
with exactly this compression level" (thus making the presence or
absence of -z moot).  If you want to specify some other compression
method altogether, use something like --lzma=N.  It seems unlikely to me
that somebody who wants to override the default compression method
wouldn't want to pick the settings for it too.
        regards, tom lane


Re: inconvenient compression options in pg_basebackup

From
Peter Eisentraut
Date:
On tor, 2011-05-26 at 16:54 -0400, Tom Lane wrote:
> But if you want to take such an extension into account right now,
> maybe we ought to design that feature now.  What are you seeing it as
> looking like?
> 
> My thought is that "-z" should just mean "give me compression; a good
> default compression setting is fine".  "-Zn" could mean "I want gzip
> with exactly this compression level" (thus making the presence or
> absence of -z moot).  If you want to specify some other compression
> method altogether, use something like --lzma=N.  It seems unlikely to
> me that somebody who wants to override the default compression method
> wouldn't want to pick the settings for it too. 

I think of pg_basebackup as analogous to tar.  tar has a bunch of
options to set a compression method (-Z, -z, -j, -J), but no support for
setting compression specific options.  So in that sense that contradicts
your suspicion.



Re: inconvenient compression options in pg_basebackup

From
Tom Lane
Date:
Peter Eisentraut <peter_e@gmx.net> writes:
> On tor, 2011-05-26 at 16:54 -0400, Tom Lane wrote:
>> But if you want to take such an extension into account right now,
>> maybe we ought to design that feature now.  What are you seeing it as
>> looking like?
>> 
>> My thought is that "-z" should just mean "give me compression; a good
>> default compression setting is fine".  "-Zn" could mean "I want gzip
>> with exactly this compression level" (thus making the presence or
>> absence of -z moot).  If you want to specify some other compression
>> method altogether, use something like --lzma=N.  It seems unlikely to
>> me that somebody who wants to override the default compression method
>> wouldn't want to pick the settings for it too. 

> I think of pg_basebackup as analogous to tar.  tar has a bunch of
> options to set a compression method (-Z, -z, -j, -J), but no support for
> setting compression specific options.  So in that sense that contradicts
> your suspicion.

I would think we'd be more concerned about preserving an analogy to
pg_dump, which most certainly does expose compression-quality options.
        regards, tom lane