Description
Based on the commentary on parent MB, it is not efficient to send compressed values unless the bandwidth / memory saving exceeds the cost of working with the compressed value.
As an extreme example, if a document compressed to exactly the same size as the input, it makes no sense to send compressed. However, the same is also true if the size savings are "too small" - clearly only saving 1B wouldn't be worth sending the document compressed either.
For a perfect algorithm, you would need to consider the benefits to compression (reduced network bandwidth / latency, reduced server memory requirements), vs the costs (time to compress, time to decompress).
However its likely we'd choose a simpler set of parameters - for example:
- Minimum document size (unlikely to recoup compression/decompression costs for documents below a given size).
- Minimum compression ratio (if we have reduced the size by less than X% then unlikely to gain enough from compression).