In MySQL, once we use the COMPRESS method to compress a particular text, the LENGTH of the resultant text is not the same as that of the original text.
However, using UNCOMPRESSED_LENGTH method on the compressed text results in the exact length of the original text, even though the text is currently compressed.
Example:
SELECT UNCOMPRESSED_LENGTH(COMPRESS('MyName'))
+-----------------------------------------+
| UNCOMPRESSED_LENGTH(COMPRESS('MyName')) |
+-----------------------------------------+
| 6 |
+-----------------------------------------+
Now, use the below query
SELECT LENGTH(COMPRESS('MyName'))
+----------------------------+
| LENGTH(COMPRESS('MyName')) |
+----------------------------+
| 18 |
+----------------------------+
This indicates the different values in length using the two different LENGTH methods.
Visit the DevX Tip Bank