Compress JSON String Stored in PostgreSQL, such as MessagePack?
Individual PostgreSQL fields over 2000 bytes are automatically compressed, for TOAST storage.  However, this compression is not very good, and is local to just that one PostgreSQL value, so can't compress out repetition that occurs between values (like the same keys being used repeatedly, but only once in each JSON structure).  You might want to look at ZSON for compression that uses the whole column for compression context (I've never use it myself).


  I am particularly interested in using JSON encoding/compression algorithms like MessagePack with zlib, but how can we use this when inserting the record into the PostgreSQL table?


You could always compress it on the client, then pass it to and from the database as bytea. Of course then you can't do JSON manipulation inside the database.  Also working with bytea is generally unpleasant.

If you can find an implementation of MessagePack in Perl or Python, you could use those pl languages to allow compression and decompression inside the database.