分页: 1 / 1
#1 新潮的数据库存string的时候应该会压缩吧?
发表于 : 2024年 5月 31日 23:45
由 wokao
说的是列存储的
有个字段是48个字符,每个字符要么是‘0’要么是‘1’,基本都是‘0’。我想给转成十进制省点空间,后来一想数据库会不会自动给我压缩?
#2 Re: 新潮的数据库存string的时候应该会压缩吧?
发表于 : 2024年 6月 1日 02:14
由 minquan
你如果学过编码,就知道utf8虽然浪费,但是不可压缩,除非你不支持亚洲文字。
#3 Re: 新潮的数据库存string的时候应该会压缩吧?
发表于 : 2024年 6月 1日 02:33
由 whitepaper
wokao 写了: 2024年 5月 31日 23:45
说的是列存储的
有个字段是48个字符,每个字符要么是‘0’要么是‘1’,基本都是‘0’。我想给转成十进制省点空间,后来一想数据库会不会自动给我压缩?
这种情况还是转成整数存放省空间点吧?64位整数就够了。
数据库也能自动压缩
MySQL implements compression with the help of the well-known zlib library, which implements the LZ77 compression algorithm. This compression algorithm is mature, robust, and efficient in both CPU utilization and in reduction of data size. The algorithm is “lossless”, so that the original uncompressed data can always be reconstructed from the compressed form. LZ77 compression works by finding sequences of data that are repeated within the data to be compressed. The patterns of values in your data determine how well it compresses, but typical user data often compresses by 50% or more.
#4 Re: 新潮的数据库存string的时候应该会压缩吧?
发表于 : 2024年 6月 1日 06:08
由 wokao
扯淡,给定每个字符非1即0,
000000100000000000000000之类不可压缩?
这是最基本的压缩
minquan 写了: 2024年 6月 1日 02:14
你如果学过编码,就知道utf8虽然浪费,但是不可压缩,除非你不支持亚洲文字。