新潮的数据库存string的时候应该会压缩吧?

STEM版,合并数学,物理,化学,科学,工程,机械。不包括生物、医学相关,和计算机相关内容。

版主: verdeliteTheMatrix

回复
头像
wokao楼主
论坛元老
论坛元老
帖子互动: 1159
帖子: 21598
注册时间: 2023年 3月 11日 19:17

#1 新潮的数据库存string的时候应该会压缩吧?

帖子 wokao楼主 »

说的是列存储的
有个字段是48个字符,每个字符要么是‘0’要么是‘1’,基本都是‘0’。我想给转成十进制省点空间,后来一想数据库会不会自动给我压缩?
头像
minquan(三民主义)
论坛精英
论坛精英
帖子互动: 191
帖子: 7431
注册时间: 2022年 7月 29日 09:12

#2 Re: 新潮的数据库存string的时候应该会压缩吧?

帖子 minquan(三民主义) »

你如果学过编码,就知道utf8虽然浪费,但是不可压缩,除非你不支持亚洲文字。
whitepaper
著名点评
著名点评
帖子互动: 75
帖子: 5070
注册时间: 2022年 7月 23日 01:07
来自: 平凡的地方

#3 Re: 新潮的数据库存string的时候应该会压缩吧?

帖子 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.
头像
wokao楼主
论坛元老
论坛元老
帖子互动: 1159
帖子: 21598
注册时间: 2023年 3月 11日 19:17

#4 Re: 新潮的数据库存string的时候应该会压缩吧?

帖子 wokao楼主 »

扯淡,给定每个字符非1即0,
000000100000000000000000之类不可压缩?

这是最基本的压缩
minquan 写了: 2024年 6月 1日 02:14 你如果学过编码,就知道utf8虽然浪费,但是不可压缩,除非你不支持亚洲文字。
回复

回到 “STEM”