Re: [PATCH] COPY .. COMPRESSED - Mailing list pgsql-hackers

From Stephen Frost
Subject Re: [PATCH] COPY .. COMPRESSED
Date
Msg-id 20130115160845.GR16126@tamriel.snowman.net
Whole thread Raw
In response to Re: [PATCH] COPY .. COMPRESSED  (Claudio Freire <klaussfreire@gmail.com>)
Responses Re: [PATCH] COPY .. COMPRESSED
List pgsql-hackers
* Claudio Freire (klaussfreire@gmail.com) wrote:
> Postgres' packetized protocol lends itself quite well for this kind of
> thing. It could even be done on a packet-by-packet basis. The only
> drawback I see, is that it pretty much rules out piping through
> arbitrary commands (a protocol needs to be very clearly defined).

Actually, wouldn't PG's packet-based protocol be exactly the wrong way
to do any kind of good on-the-wire compression?  You certainly wouldn't
want to waste time compressing small packets, such as a single INSERT
command or similar, as you'll always have to send a packet out anyway.
Even doing it at the protocol level with something ssl-like, where
you wrap the entire connection, wouldn't help if the client has a
process along the lines of:

send INSERT command
wait for response
send INSERT command
wait for response
..
..

Since you'd still have to flush after each small bit of data.

Where it does work well is when you move into a bulk-data mode (ala
COPY) and can compress relatively large amounts of data into a smaller
number of full-size packets to be sent.
Thanks,
    Stephen

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_ctl idempotent option
Next
From: Tom Lane
Date:
Subject: Re: logical changeset generation v4