Understanding UNCOMPRESSED_LENGTH in MySQL

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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Related Posts