当前位置: 首页 > news >正文

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 |                | pcmax     |                | pxmax     |                | pcmin     |                | pxmin     |                | pctid     |                | pid       |                | pname     | 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 |                | pcmax     |                | pxmax     |                | pcmin     |                | pxmin     |                | pctid     |                | pid       |                | pname     | 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)

–未完待续

相关文章:

PostgreSQL 字段使用pglz压缩测试

PostgreSQL 字段使用pglz压缩测试 测试一: 创建测试表 yewu1.test1,并插入1000w行数据 创建测试表 yewu1.test2,使用 pglz压缩字段,并插入1000w行数据–创建测试表1,并插入1000w行数据 white# create table yewu1.t…...

基于大数据的学生体质健康信息系统

作者:计算机学姐 开发技术:SpringBoot、SSM、Vue、MySQL、JSP、ElementUI、Python、小程序等,“文末源码”。 专栏推荐:前后端分离项目源码、SpringBoot项目源码、Vue项目源码、SSM项目源码、微信小程序源码 精品专栏:…...

【STM32】 TCP/IP通信协议(1)--LwIP介绍

一、前言 TCP/IP是干啥的?它跟SPI、IIC、CAN有什么区别?它如何实现stm32的通讯?如何去配置?为了搞懂这些问题,查询资料可解决如下疑问: 1.为什么要用以太网通信? 以太网(Ethernet) 是指遵守 IEEE 802.3 …...

828华为云征文|部署音乐流媒体服务器 mStream

828华为云征文|部署音乐流媒体服务器 mStream 一、Flexus云服务器X实例介绍二、Flexus云服务器X实例配置2.1 重置密码2.2 服务器连接2.3 安全组配置2.4 Docker 环境搭建 三、Flexus云服务器X实例部署 mStream3.1 mStream 介绍3.2 mStream 部署3.3 mStream 使用 四、…...

【动态规划-最长公共子序列(LCS)】力扣712. 两个字符串的最小ASCII删除和

给定两个字符串s1 和 s2,返回 使两个字符串相等所需删除字符的 ASCII 值的最小和 。 示例 1: 输入: s1 “sea”, s2 “eat” 输出: 231 解释: 在 “sea” 中删除 “s” 并将 “s” 的值(115)加入总和。 在 “eat” 中删除 “t” 并将 116 加入总和。 结束时&…...

override

override 是 C11 引入的一个关键字,override 的作用是在派生类中显式地声明某个函数是用于重写基类的虚函数。它不仅仅是一个语法标记,更重要的是提供了编译时的错误检查功能,确保程序员确实按照预期在派生类中重写了基类的函数。如果没有正确…...

万象奥科工业平板上线,邀您体验与众不同!

Vanxoak推出的全新品类——ARM工业平板电脑!该系列工业平板具有防护等级高、接口丰富、易开发等特点,专为工业HMI(人机界面)和工业控制领域设计。整机采用高性能工业级ARM处理器,适配全贴合电容触摸屏,可选…...

java将word转pdf

总结 建议使用aspose-words转pdf,poi的容易出问题还丑… poi的(多行的下边框就不对了) aspose-words的(基本和word一样) poi工具转换 <!-- 处理PDF --><dependency><groupId>fr.opensagres.xdocreport</groupId><artifactId>fr.opensagres…...

Golang | Leetcode Golang题解之第449题序列化和反序列化二叉搜索树

题目&#xff1a; 题解&#xff1a; type Codec struct{}func Constructor() (_ Codec) { return }func (Codec) serialize(root *TreeNode) string {arr : []string{}var postOrder func(*TreeNode)postOrder func(node *TreeNode) {if node nil {return}postOrder(node.Le…...

基于SpringBoot+Vue+MySQL的美食信息推荐系统

系统展示 用户前台界面 管理员后台界面 系统背景 在数字化时代&#xff0c;随着人们对美食文化的热爱与追求不断增长&#xff0c;美食信息推荐系统成为了连接食客与美食之间的重要桥梁。面对海量的美食信息&#xff0c;用户往往难以快速找到符合个人口味和需求的美食。因此&…...

spring boot jar 分离自动部署脚本

背景 远程部署时spring boot 包&#xff0c;比较大。可以采用依赖库和业务包分离的方式。提供一个脚本进行自动部署 maven 配置分离jar包 <build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.springfra…...

PGMP-03战略一致性

1.概要 program strategy alignment&#xff1a;战略一致性 2.详细...

华为OD机试真题---智能成绩表

题目描述 小明来到某学校当老师&#xff0c;需要将学生按考试总分或单科分数进行排名。输入包括学生人数、科目数量、科目名称、每个学生的姓名和对应科目的成绩&#xff0c;最后输入一个用作排名的科目名称。如果输入的排名科目不存在&#xff0c;则按总分进行排序。输出一行…...

828华为云征文 | 华为云Flexus云服务器X实例搭建企业内部VPN私有隧道,以实现安全远程办公

VPN虚拟专用网络适用于企业内部人员流动频繁和远程办公的情况&#xff0c;出差员工或在家办公的员工利用当地ISP就可以和企业的VPN网关建立私有的隧道连接。 通过拨入当地的ISP进入Internet再连接企业的VPN网关&#xff0c;在用户和VPN网关之间建立一个安全的“隧道”&#xff…...

Hadoop集群的高可用(HA):NameNode和resourcemanager高可用的搭建

文章目录 一、NameNode高可用的搭建1、免密配置2、三个节点都需要安装psmisc3、检查三个节点是否都安装jdk以及zk4、检查是否安装了hadoop集群5、修改hadoop-env.sh6、修改core-site.xml7、修改hdfs-site.xml8、检查workers 文件是否为三台服务9、分发给其他两个节点10、初始化…...

支付宝沙箱环境 支付

一 什么是沙箱&#xff1a; 沙箱环境是支付宝开放平台为开发者提供的安全低门槛的测试环境 支付宝正式和沙箱环境的区别 &#xff1a; AI&#xff1a; 从沙箱到正式环境&#xff1a; 当应用程序开发完成后&#xff0c;需要将应用程序从沙箱环境迁移到正式环境。 这通常涉及…...

获取unity中prefab的中文文本内容以及和prefab有关的问题

背景1&#xff1a;经常会在开发中遇到策划需要改某个界面&#xff0c;但是我们不知道那是什么界面&#xff0c;只看到一些关键字比如圣诞活动&#xff0c;那这样我就可以轻易找到这个预设了。另外还可以扩展就是收集项目中的所有中文文本然后归集到多语言表中&#xff0c;然后接…...

Web自动化中常用XPath定位方式

在进行Web自动化测试时&#xff0c;元素定位是一个至关重要的环节。XPath&#xff08;XML Path Language&#xff09;是一种用于在XML文档中定位节点的语言。在Web自动化中&#xff0c;XPath广泛应用于定位HTML元素。本文将详细介绍几种常用的XPath定位方式&#xff0c;包括绝对…...

Unity3D播放GIF图片使用Animation来制作动画

系列文章目录 unity工具 文章目录 系列文章目录👉前言👉一、下载GIF动图,用PS制作导出帧动画图片👉二、使用Animation制作动画👉三、脚本控制动画播放👉壁纸分享👉总结👉前言 unity播放gif图片,本身是不支持的,但是可以使用其他方法来实现, 1.有一种使用System…...

redo log 和 bin log 的两阶段提交

两阶段提交的过程 当事务提交后&#xff0c;有一个两阶段提交策略。 在开启两阶段提交时&#xff0c;会开启一个 XA 事务&#xff08;宏观上的事务&#xff09;&#xff0c; Prepare 阶段&#xff1a;将 redo log 的状态设置为 prepare&#xff0c;然后将 事务XID 写入 redo…...

Java 语言特性(面试系列2)

一、SQL 基础 1. 复杂查询 &#xff08;1&#xff09;连接查询&#xff08;JOIN&#xff09; 内连接&#xff08;INNER JOIN&#xff09;&#xff1a;返回两表匹配的记录。 SELECT e.name, d.dept_name FROM employees e INNER JOIN departments d ON e.dept_id d.dept_id; 左…...

大语言模型如何处理长文本?常用文本分割技术详解

为什么需要文本分割? 引言:为什么需要文本分割?一、基础文本分割方法1. 按段落分割(Paragraph Splitting)2. 按句子分割(Sentence Splitting)二、高级文本分割策略3. 重叠分割(Sliding Window)4. 递归分割(Recursive Splitting)三、生产级工具推荐5. 使用LangChain的…...

将对透视变换后的图像使用Otsu进行阈值化,来分离黑色和白色像素。这句话中的Otsu是什么意思?

Otsu 是一种自动阈值化方法&#xff0c;用于将图像分割为前景和背景。它通过最小化图像的类内方差或等价地最大化类间方差来选择最佳阈值。这种方法特别适用于图像的二值化处理&#xff0c;能够自动确定一个阈值&#xff0c;将图像中的像素分为黑色和白色两类。 Otsu 方法的原…...

MySQL 知识小结(一)

一、my.cnf配置详解 我们知道安装MySQL有两种方式来安装咱们的MySQL数据库&#xff0c;分别是二进制安装编译数据库或者使用三方yum来进行安装,第三方yum的安装相对于二进制压缩包的安装更快捷&#xff0c;但是文件存放起来数据比较冗余&#xff0c;用二进制能够更好管理咱们M…...

GitHub 趋势日报 (2025年06月06日)

&#x1f4ca; 由 TrendForge 系统生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日获星趋势图 今日获星趋势图 590 cognee 551 onlook 399 project-based-learning 348 build-your-own-x 320 ne…...

iview框架主题色的应用

1.下载 less要使用3.0.0以下的版本 npm install less2.7.3 npm install less-loader4.0.52./src/config/theme.js文件 module.exports {yellow: {theme-color: #FDCE04},blue: {theme-color: #547CE7} }在sass中使用theme配置的颜色主题&#xff0c;无需引入&#xff0c;直接可…...

NPOI操作EXCEL文件 ——CAD C# 二次开发

缺点:dll.版本容易加载错误。CAD加载插件时&#xff0c;没有加载所有类库。插件运行过程中用到某个类库&#xff0c;会从CAD的安装目录找&#xff0c;找不到就报错了。 【方案2】让CAD在加载过程中把类库加载到内存 【方案3】是发现缺少了哪个库&#xff0c;就用插件程序加载进…...

Caliper 负载(Workload)详细解析

Caliper 负载(Workload)详细解析 负载(Workload)是 Caliper 性能测试的核心部分,它定义了测试期间要执行的具体合约调用行为和交易模式。下面我将全面深入地讲解负载的各个方面。 一、负载模块基本结构 一个典型的负载模块(如 workload.js)包含以下基本结构: use strict;/…...

PostgreSQL——环境搭建

一、Linux # 安装 PostgreSQL 15 仓库 sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm# 安装之前先确认是否已经存在PostgreSQL rpm -qa | grep postgres# 如果存在&#xff0…...

如何在Windows本机安装Python并确保与Python.NET兼容

✅作者简介&#xff1a;2022年博客新星 第八。热爱国学的Java后端开发者&#xff0c;修心和技术同步精进。 &#x1f34e;个人主页&#xff1a;Java Fans的博客 &#x1f34a;个人信条&#xff1a;不迁怒&#xff0c;不贰过。小知识&#xff0c;大智慧。 &#x1f49e;当前专栏…...