PostgreSQL 字段使用pglz压缩测试

PostgreSQL 字段使用pglz压缩测试

测试一:

创建测试表 yewu1.test1,并插入1000w行数据
创建测试表 yewu1.test2,使用 pglz压缩字段,并插入1000w行数据

–创建测试表1,并插入1000w行数据

white=# create table yewu1.test1 (name varchar(20));
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test1'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | 
(7 rows)
white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test1 VALUES ('white ' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test1')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

–创建测试表2,使用 pglz压缩字段,并插入1000w行数据

white=# 
white=# create table yewu1.test2 (name varchar(20) COMPRESSION pglz);
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test2'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | p
(7 rows)
white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test2 VALUES ('white ' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test2')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

对比表yewu1.test1和yewu1.test2的大小,没体现出压缩了。

测试二:

创建测试表 yewu1.test3,text数据类型,并插入1000w行数据
创建测试表 yewu1.test4,text数据类型,使用 pglz压缩字段,并插入1000w行数据

–创建测试表3,并插入1000w行数据

white=# create table yewu1.test3 (name text);
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test3'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | 
(7 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test3 VALUES ('white ' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test3')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

–创建测试表4,使用 pglz压缩字段,并插入1000w行数据

white=# create table yewu1.test4 (name text COMPRESSION pglz);
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test4'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | p
(7 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test4 VALUES ('white ' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test4')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

对比表yewu1.test3和yewu1.test4的大小,没体现出压缩了。

测试三:

创建测试表 yewu1.test5,text数据类型,并插入1000w行重复的数据
创建测试表 yewu1.test6,text数据类型,使用 pglz压缩字段,并插入1000w行重复的数据

–创建测试表5,并插入1000w行重复的数据

white=# create table yewu1.test5 (name text);
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test5'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | 
(7 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test5 VALUES ('white12345678');
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test5')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

–创建测试表6,使用 pglz压缩字段,并插入1000w行重复的数据

white=# create table yewu1.test6 (name text COMPRESSION pglz);
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test6'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 name     | p
(7 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test6 VALUES ('white12345678');
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test6')) AS table_size;
 table_size 
------------
 422 MB
(1 row)

对比表yewu1.test5和yewu1.test6的大小,没体现出压缩了。

测试四:

创建测试表 yewu1.test7,带有主键,text数据类型,并插入1000w行重复的数据
创建测试表 yewu1.test8,带有主键,text数据类型,使用 pglz压缩字段,并插入1000w行重复的数据

–创建测试表7,带有主键,并插入1000w行重复的数据

white=# create table yewu1.test7 (
white(#     id serial primary key,
white(#     name text
white(# );
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test7'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 id       | 
 name     | 
(8 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test7 VALUES (aa,'white' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test7')) AS table_size;
 table_size 
------------
 490 MB
(1 row)

–创建测试表8,带有主键,使用 pglz压缩字段,并插入1000w行重复的数据

white=# create table yewu1.test8 (
white(#     id serial primary key,
white(#     name text COMPRESSION pglz
white(# );
CREATE TABLE
white=# 
white=# SELECT attname, attcompression
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test8'::regclass;
 attname  | attcompression 
----------+----------------
 tableoid | 
 cmax     | 
 xmax     | 
 cmin     | 
 xmin     | 
 ctid     | 
 id       | 
 name     | p
(8 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test8 VALUES (aa,'white' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test8')) AS table_size;
 table_size 
------------
 490 MB
(1 row)

对比表yewu1.test7和yewu1.test8的大小,没体现出压缩了。

测试五:

清空测试表 yewu1.test8,并修改字段存储类型为MAIN,再插入1000w行重复的数据

–清空测试表8,并修改字段存储类型为MAIN,再插入1000w行重复的数据

white=# truncate table yewu1.test8;
TRUNCATE TABLE
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test8')) AS table_size;
 table_size 
------------
 8192 bytes
(1 row)

white=# 
white=# SELECT attname, attcompression,attstorage
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test8'::regclass;
 attname  | attcompression | attstorage 
----------+----------------+------------
 tableoid |                | p
 cmax     |                | p
 xmax     |                | p
 cmin     |                | p
 xmin     |                | p
 ctid     |                | p
 id       |                | p
 name     | p              | x
(8 rows)

white=# 
white=# ALTER TABLE yewu1.test8 ALTER COLUMN name SET STORAGE MAIN;
ALTER TABLE
white=# SELECT attname, attcompression,attstorage
white-# FROM pg_attribute
white-# WHERE attrelid = 'yewu1.test8'::regclass;
 attname  | attcompression | attstorage 
----------+----------------+------------
 tableoid |                | p
 cmax     |                | p
 xmax     |                | p
 cmin     |                | p
 xmin     |                | p
 ctid     |                | p
 id       |                | p
 name     | p              | m
(8 rows)

white=# 
white=# DO $$
white$# DECLARE aa INTEGER;
white$# BEGIN
white$#     FOR aa IN 1..10000000 LOOP
white$#         INSERT INTO yewu1.test8 VALUES (aa,'white' || aa);
white$# END LOOP;
white$# COMMIT;
white$# END $$;
DO
white=# 
white=# SELECT pg_size_pretty(pg_table_size('yewu1.test8')) AS table_size;
 table_size 
------------
 490 MB
(1 row)

–未完待续。思路错了,pg的压缩表有限制

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/887188.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

记录一次病毒启动脚本

在第一次下载软件时,目录中配了一个使用说明,说是需要通过start.bat 这个文件来启动程序,而这个 start.bat 就是始作俑者: 病毒作者比较狡猾,其中start.bat 用记事本打开是乱码,但是可以通过将这个批处理…

小程序 uniapp+Android+hbuilderx体育场地预约管理系统的设计与实现

目录 项目介绍支持以下技术栈:具体实现截图HBuilderXuniappmysql数据库与主流编程语言java类核心代码部分展示登录的业务流程的顺序是:数据库设计性能分析操作可行性技术可行性系统安全性数据完整性软件测试详细视频演示源码获取方式 项目介绍 用户 注册…

探索 Python 虚拟环境的奥秘:virtualenv 的魔法世界

文章目录 探索 Python 虚拟环境的奥秘:virtualenv 的魔法世界背景:为何选择 virtualenv?虚拟环境的守护者:virtualenv 是什么?安装 virtualenv:简单几步,开启隔离之旅掌握 virtualenv 的基本用法…

LC刷题专题:堆、大顶堆、小顶堆

文章目录 692. 前K个高频单词215. 数组中的第K个最大元素2336、无限集中的最小数字 这篇文章以后记录自己刷到的题目中与堆有关的。 692. 前K个高频单词 这个题目整体不难,是前k个高频元素的改进版,只需要在创建小顶堆时执行排序规则即可。如果出现次数…

镜头、diffuser、DOE

三种常见的光学器件:镜头、扩散器(diffuser)、衍射光学元件(DOE) lensdiffuserDOE镜头扩散器衍射光学器件作用聚焦或发散均匀化光束生成特定形状的光斑应用领域TOF结构光算法 1.1 镜头(Lens) …

微服务_3.微服务保护

文章目录 一、微服务雪崩及解决方法1.1、超时处理1.2、仓壁模式1.3、断路器1.4、限流 二、Sentinel2.1、流量控制2.1.1、普通限流2.1.2、热点参数限流 2.2、线程隔离2.3、熔断降级2.3.1、断路器状态机2.3.2、断路器熔断策略2.3.2.1、慢调用2.3.2.2、异常比例,异常数…

(12)MATLAB莱斯(Rician)衰落信道仿真2补充:莱斯衰落信道与莱斯随机变量

文章目录 前言1.关于莱斯衰落信道仿真的两个公式2.由式(1)推出式(2) 前言 本文给出关于莱斯衰落信道仿真的两个公式之间的推导。 1.关于莱斯衰落信道仿真的两个公式 在上一篇《(11)MATLAB莱斯&#xff08…

产品经理产出的原型设计 - 需求文档应该怎么制作?

需求文档,产品经理最终产出的文档,也是产品设计最终的表述形式。本次分享呢,就是介绍如何写好一份需求文档。 所有元件均可复用,可作为管理端原型设计模板,按照实际项目需求进行功能拓展。有需要的话可分享源文件。 …

Origin正态分布检验

在spass中用Shapiro-Wilk检验--正态分布检测 Shapiro-Wilk检验--正态分布检测_spss shapiro-wilk检验-CSDN博客

用 LoRA 微调 Stable Diffusion:拆开炼丹炉,动手实现你的第一次 AI 绘画

总得拆开炼丹炉看看是什么样的。这篇文章将带你从代码层面一步步实现 AI 文本生成图像(Text-to-Image)中的 LoRA 微调过程,你将: 了解 Trigger Words(触发词)到底是什么,以及它们如何影响生成结…

HTTPS协议简单介绍

HTTP协议简单介绍HTTP协议简单介绍-CSDN博客 目录 一、对称加密和非对称加密 对称加密 非对称加密 总结 二、HTTPS协议 定义 关键特点 工作原理 详细通信过程 1. 客户端请求连接 2. 服务器响应 3. 密钥交换 4. 加密通信 5. 关闭连接 ​编辑 优势 缺点 1. 性能…

leetcode35--搜索插入位置--二分查找刷题

搜索插入位置 一共会出现下面四种情况: 目标值在数组所有元素之前 目标值等于数组中某一个元素 目标值插入数组中的位置 目标值在数组所有元素之后 首先在二分查找的代码之前处理掉目标值在数组所有元素之前和之后的情况如果目标值在数组中的某个位置&#xff0c…

setTimeout,setInterval ,requestAnimationFrame定时器

setTimeout,setInterval ,requestAnimationFrame定时器 定时器函数通常用于执行定时任务,也就是说你做了一个功能放在定时器函数里,它可以在特定的时间去执行你的指令,或者说隔多长时间(单位时间内—毫秒为…

关于cefsharp访问iqiyi.com显示403 Forbidden解决办法(2种方法)

1.cefsharp浏览器访问iqiyi.com异常 (403 Forbidden) 403 Forbidden Q_DENY: Forbidden by iQIYI WAF! Any problem, contact iQIYI Security Group (security-help). Request ID: c0597b5aeead125907f7 2.解决办法(2种) 1)屏蔽掉 cefSettings.UserAgent2)修改 cefSettings…

酒店智能门锁SDK接口pro[V10] 门锁校验C#-SAAS本地化-未来之窗行业应用跨平台架构

一、代码 int 酒店标识_int Convert.ToInt32(酒店标识);StringBuilder 锁号2024 new StringBuilder(8);//信息 "未知返回值:" bufCard_原始;GetGuestLockNoByCardDataStr_原始(酒店标识_int, bufCard_原始.ToString(), 锁号2024);StringBuilder 退…

.NET Core 高性能并发编程

一、高性能大并发架构设计 .NET Core 是一个高性能、可扩展的开发框架,可以用于构建各种类型的应用程序,包括高性能大并发应用程序。为了设计和开发高性能大并发 .NET Core 应用程序,需要考虑以下几个方面: 1. 异步编程 异步编程…

开发环境简单介绍

目录 开发环境keil的安装和使用 keil的介绍 keil的安装 keil的简单使用 STC-ISP的安装 STC-ISP简单介绍 开发环境测试 总结 开发环境keil的安装和使用 keil的介绍 Keil uVision5是一个集成开发环境(IDE),用于对嵌入式系统中的微控制器…

Windows 11 安装配置 Git 教程

目录 Git Windows 11 环境安装配置 Git Git Git是一个开源的分布式版本控制系统,由Linus Torvalds创建,用于有效、高速地处理从小到大的项目版本管理。Git是目前世界上最流行的版本控制系统,广泛应用于软件开发中。 以下是Git的一些关键特…

如何用深度神经网络预测潜在消费者

1. 模型架构 本项目采用的是DeepFM模型,其结构结合了FM(因子分解机)与深度神经网络(DNN),实现了低阶与高阶特征交互的有效建模。模型分为以下几层: 1.1 FM部分(因子分解机层&#…

深入探究:在双链表指定元素的后面进行插入操作的顺序

归纳编程学习的感悟, 记录奋斗路上的点滴, 希望能帮到一样刻苦的你! 如有不足欢迎指正! 共同学习交流! 🌎欢迎各位→点赞 👍 收藏⭐ 留言​📝惟有主动付出,才有丰富的果…