Mysql – function in MySQL that will compress the results returned from a query


I would like to compress the results if it reached a certain number of rows.

The client program would then uncompress the result and process.

This a desktop with a client/server architecture, some clients connects through vpn.

When a client connects, it will send data to the server. After the server has done processing, the client will then download updated data from the server.

The clients are located in several towns, with average of 50-100 kms. away. They will connect through internet using vpn. But that is the initial plan, not implemented yet, using vpn or other means.

Best Solution

There is the COMPRESS function which can be used to compress strings into binary strings. However, depending on your needs that may not really address the problem especially since database records are usually already very compact by their very nature so I'm not certain how much benefit you'll receive from attempting further compression of the result set.

One thing you need to be careful of is premature optimization. Oftentimes you can introduce unneeded complexity and actually hurt performance if you attempt to optimize prior to correctly identifying actual bottlenecks and not just shooting blindly at the possible ones.

In that vein I would ask if you have actually identified a bottleneck in your application? If so, where exactly is it and what is its nature? What environment are you working in? Is this web development or desktop with a client/server architecture?

Perhaps you can add some of this additional information to your question and then it would be possible to better assist you?