Compresses a string and returns the result as a binary string. This function requires MySQL to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The return value is also NULL if string_to_compress is NULL. The compressed string can be uncompressed with UNCOMPRESS().
SELECT LENGTH(COMPRESS(REPEAT('a',1000)));
21
SELECT LENGTH(COMPRESS(''));
0
SELECT LENGTH(COMPRESS('a'));
13
SELECT LENGTH(COMPRESS(REPEAT('a',16)));
15
The compressed string contents are stored the following way:
SELECT LENGTH(COMPRESS(REPEAT('a',1000)));
21
SELECT LENGTH(COMPRESS(''));
0
SELECT LENGTH(COMPRESS('a'));
13
SELECT LENGTH(COMPRESS(REPEAT('a',16)));
15