I need to store large amounts of text in Postgres, mainly command logs and the output of long running commands and need to know if there are some settings that could help compress the data transparently with a tool like zlib, or some other native space saving methods.

The data is primarily read only data, so writing is not a problem.

  • 3
    from the manual: "Long strings are compressed by the system automatically" and here is a more detailed description: postgresql.org/docs/current/static/storage-toast.html – a_horse_with_no_name May 17 '15 at 9:24
  • 3
    We use quite a low ratio compression algorithm though, because it must have a low CPU cost. So it can still be worth doing another form of compresion and setting EXTERNAL storage on the column. – Craig Ringer May 18 '15 at 0:25
  • @CraigRinger When you say another form of compression do you mean setting some additional Postgres options, or compiling some additional module, whether a ready made library or one of your own? – vfclists May 18 '15 at 10:28

By default Postgres automatically compresses everything TEXT. It uses a simple lzcompress algorythm:


There is a plugin that will probably evolve to LZ4 compression support for TEXT:


There is a FDW that also support compression:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.