当前位置: 首页 > 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…...

vscode里如何用git

打开vs终端执行如下&#xff1a; 1 初始化 Git 仓库&#xff08;如果尚未初始化&#xff09; git init 2 添加文件到 Git 仓库 git add . 3 使用 git commit 命令来提交你的更改。确保在提交时加上一个有用的消息。 git commit -m "备注信息" 4 …...

【根据当天日期输出明天的日期(需对闰年做判定)。】2022-5-15

缘由根据当天日期输出明天的日期(需对闰年做判定)。日期类型结构体如下&#xff1a; struct data{ int year; int month; int day;};-编程语言-CSDN问答 struct mdata{ int year; int month; int day; }mdata; int 天数(int year, int month) {switch (month){case 1: case 3:…...

python打卡day49

知识点回顾&#xff1a; 通道注意力模块复习空间注意力模块CBAM的定义 作业&#xff1a;尝试对今天的模型检查参数数目&#xff0c;并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...

FFmpeg 低延迟同屏方案

引言 在实时互动需求激增的当下&#xff0c;无论是在线教育中的师生同屏演示、远程办公的屏幕共享协作&#xff0c;还是游戏直播的画面实时传输&#xff0c;低延迟同屏已成为保障用户体验的核心指标。FFmpeg 作为一款功能强大的多媒体框架&#xff0c;凭借其灵活的编解码、数据…...

Vue3 + Element Plus + TypeScript中el-transfer穿梭框组件使用详解及示例

使用详解 Element Plus 的 el-transfer 组件是一个强大的穿梭框组件&#xff0c;常用于在两个集合之间进行数据转移&#xff0c;如权限分配、数据选择等场景。下面我将详细介绍其用法并提供一个完整示例。 核心特性与用法 基本属性 v-model&#xff1a;绑定右侧列表的值&…...

安宝特方案丨船舶智造的“AR+AI+作业标准化管理解决方案”(装配)

船舶制造装配管理现状&#xff1a;装配工作依赖人工经验&#xff0c;装配工人凭借长期实践积累的操作技巧完成零部件组装。企业通常制定了装配作业指导书&#xff0c;但在实际执行中&#xff0c;工人对指导书的理解和遵循程度参差不齐。 船舶装配过程中的挑战与需求 挑战 (1…...

JS设计模式(4):观察者模式

JS设计模式(4):观察者模式 一、引入 在开发中&#xff0c;我们经常会遇到这样的场景&#xff1a;一个对象的状态变化需要自动通知其他对象&#xff0c;比如&#xff1a; 电商平台中&#xff0c;商品库存变化时需要通知所有订阅该商品的用户&#xff1b;新闻网站中&#xff0…...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)

前言&#xff1a; 双亲委派机制对于面试这块来说非常重要&#xff0c;在实际开发中也是经常遇见需要打破双亲委派的需求&#xff0c;今天我们一起来探索一下什么是双亲委派机制&#xff0c;在此之前我们先介绍一下类的加载器。 目录 ​编辑 前言&#xff1a; 类加载器 1. …...

手机平板能效生态设计指令EU 2023/1670标准解读

手机平板能效生态设计指令EU 2023/1670标准解读 以下是针对欧盟《手机和平板电脑生态设计法规》(EU) 2023/1670 的核心解读&#xff0c;综合法规核心要求、最新修正及企业合规要点&#xff1a; 一、法规背景与目标 生效与强制时间 发布于2023年8月31日&#xff08;OJ公报&…...

「全栈技术解析」推客小程序系统开发:从架构设计到裂变增长的完整解决方案

在移动互联网营销竞争白热化的当下&#xff0c;推客小程序系统凭借其裂变传播、精准营销等特性&#xff0c;成为企业抢占市场的利器。本文将深度解析推客小程序系统开发的核心技术与实现路径&#xff0c;助力开发者打造具有市场竞争力的营销工具。​ 一、系统核心功能架构&…...