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题序列化和反序列化二叉搜索树
题目: 题解: 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的美食信息推荐系统
系统展示 用户前台界面 管理员后台界面 系统背景 在数字化时代,随着人们对美食文化的热爱与追求不断增长,美食信息推荐系统成为了连接食客与美食之间的重要桥梁。面对海量的美食信息,用户往往难以快速找到符合个人口味和需求的美食。因此&…...
spring boot jar 分离自动部署脚本
背景 远程部署时spring boot 包,比较大。可以采用依赖库和业务包分离的方式。提供一个脚本进行自动部署 maven 配置分离jar包 <build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.springfra…...
PGMP-03战略一致性
1.概要 program strategy alignment:战略一致性 2.详细...
华为OD机试真题---智能成绩表
题目描述 小明来到某学校当老师,需要将学生按考试总分或单科分数进行排名。输入包括学生人数、科目数量、科目名称、每个学生的姓名和对应科目的成绩,最后输入一个用作排名的科目名称。如果输入的排名科目不存在,则按总分进行排序。输出一行…...
828华为云征文 | 华为云Flexus云服务器X实例搭建企业内部VPN私有隧道,以实现安全远程办公
VPN虚拟专用网络适用于企业内部人员流动频繁和远程办公的情况,出差员工或在家办公的员工利用当地ISP就可以和企业的VPN网关建立私有的隧道连接。 通过拨入当地的ISP进入Internet再连接企业的VPN网关,在用户和VPN网关之间建立一个安全的“隧道”ÿ…...
Hadoop集群的高可用(HA):NameNode和resourcemanager高可用的搭建
文章目录 一、NameNode高可用的搭建1、免密配置2、三个节点都需要安装psmisc3、检查三个节点是否都安装jdk以及zk4、检查是否安装了hadoop集群5、修改hadoop-env.sh6、修改core-site.xml7、修改hdfs-site.xml8、检查workers 文件是否为三台服务9、分发给其他两个节点10、初始化…...
支付宝沙箱环境 支付
一 什么是沙箱: 沙箱环境是支付宝开放平台为开发者提供的安全低门槛的测试环境 支付宝正式和沙箱环境的区别 : AI: 从沙箱到正式环境: 当应用程序开发完成后,需要将应用程序从沙箱环境迁移到正式环境。 这通常涉及…...
获取unity中prefab的中文文本内容以及和prefab有关的问题
背景1:经常会在开发中遇到策划需要改某个界面,但是我们不知道那是什么界面,只看到一些关键字比如圣诞活动,那这样我就可以轻易找到这个预设了。另外还可以扩展就是收集项目中的所有中文文本然后归集到多语言表中,然后接…...
Web自动化中常用XPath定位方式
在进行Web自动化测试时,元素定位是一个至关重要的环节。XPath(XML Path Language)是一种用于在XML文档中定位节点的语言。在Web自动化中,XPath广泛应用于定位HTML元素。本文将详细介绍几种常用的XPath定位方式,包括绝对…...
Unity3D播放GIF图片使用Animation来制作动画
系列文章目录 unity工具 文章目录 系列文章目录👉前言👉一、下载GIF动图,用PS制作导出帧动画图片👉二、使用Animation制作动画👉三、脚本控制动画播放👉壁纸分享👉总结👉前言 unity播放gif图片,本身是不支持的,但是可以使用其他方法来实现, 1.有一种使用System…...
redo log 和 bin log 的两阶段提交
两阶段提交的过程 当事务提交后,有一个两阶段提交策略。 在开启两阶段提交时,会开启一个 XA 事务(宏观上的事务), Prepare 阶段:将 redo log 的状态设置为 prepare,然后将 事务XID 写入 redo…...
(LeetCode 每日一题) 3442. 奇偶频次间的最大差值 I (哈希、字符串)
题目:3442. 奇偶频次间的最大差值 I 思路 :哈希,时间复杂度0(n)。 用哈希表来记录每个字符串中字符的分布情况,哈希表这里用数组即可实现。 C版本: class Solution { public:int maxDifference(string s) {int a[26]…...
智慧医疗能源事业线深度画像分析(上)
引言 医疗行业作为现代社会的关键基础设施,其能源消耗与环境影响正日益受到关注。随着全球"双碳"目标的推进和可持续发展理念的深入,智慧医疗能源事业线应运而生,致力于通过创新技术与管理方案,重构医疗领域的能源使用模式。这一事业线融合了能源管理、可持续发…...
模型参数、模型存储精度、参数与显存
模型参数量衡量单位 M:百万(Million) B:十亿(Billion) 1 B 1000 M 1B 1000M 1B1000M 参数存储精度 模型参数是固定的,但是一个参数所表示多少字节不一定,需要看这个参数以什么…...
day52 ResNet18 CBAM
在深度学习的旅程中,我们不断探索如何提升模型的性能。今天,我将分享我在 ResNet18 模型中插入 CBAM(Convolutional Block Attention Module)模块,并采用分阶段微调策略的实践过程。通过这个过程,我不仅提升…...
基于服务器使用 apt 安装、配置 Nginx
🧾 一、查看可安装的 Nginx 版本 首先,你可以运行以下命令查看可用版本: apt-cache madison nginx-core输出示例: nginx-core | 1.18.0-6ubuntu14.6 | http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages ng…...
Mac软件卸载指南,简单易懂!
刚和Adobe分手,它却总在Library里给你写"回忆录"?卸载的Final Cut Pro像电子幽灵般阴魂不散?总是会有残留文件,别慌!这份Mac软件卸载指南,将用最硬核的方式教你"数字分手术"࿰…...
NLP学习路线图(二十三):长短期记忆网络(LSTM)
在自然语言处理(NLP)领域,我们时刻面临着处理序列数据的核心挑战。无论是理解句子的结构、分析文本的情感,还是实现语言的翻译,都需要模型能够捕捉词语之间依时序产生的复杂依赖关系。传统的神经网络结构在处理这种序列依赖时显得力不从心,而循环神经网络(RNN) 曾被视为…...
C# 求圆面积的程序(Program to find area of a circle)
给定半径r,求圆的面积。圆的面积应精确到小数点后5位。 例子: 输入:r 5 输出:78.53982 解释:由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982,因为我们只保留小数点后 5 位数字。 输…...
ABAP设计模式之---“简单设计原则(Simple Design)”
“Simple Design”(简单设计)是软件开发中的一个重要理念,倡导以最简单的方式实现软件功能,以确保代码清晰易懂、易维护,并在项目需求变化时能够快速适应。 其核心目标是避免复杂和过度设计,遵循“让事情保…...
九天毕昇深度学习平台 | 如何安装库?
pip install 库名 -i https://pypi.tuna.tsinghua.edu.cn/simple --user 举个例子: 报错 ModuleNotFoundError: No module named torch 那么我需要安装 torch pip install torch -i https://pypi.tuna.tsinghua.edu.cn/simple --user pip install 库名&#x…...
