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…...
JavaScript 中的 ES|QL:利用 Apache Arrow 工具
作者:来自 Elastic Jeffrey Rengifo 学习如何将 ES|QL 与 JavaScript 的 Apache Arrow 客户端工具一起使用。 想获得 Elastic 认证吗?了解下一期 Elasticsearch Engineer 培训的时间吧! Elasticsearch 拥有众多新功能,助你为自己…...
Oracle查询表空间大小
1 查询数据库中所有的表空间以及表空间所占空间的大小 SELECTtablespace_name,sum( bytes ) / 1024 / 1024 FROMdba_data_files GROUP BYtablespace_name; 2 Oracle查询表空间大小及每个表所占空间的大小 SELECTtablespace_name,file_id,file_name,round( bytes / ( 1024 …...
PPT|230页| 制造集团企业供应链端到端的数字化解决方案:从需求到结算的全链路业务闭环构建
制造业采购供应链管理是企业运营的核心环节,供应链协同管理在供应链上下游企业之间建立紧密的合作关系,通过信息共享、资源整合、业务协同等方式,实现供应链的全面管理和优化,提高供应链的效率和透明度,降低供应链的成…...
Go 语言接口详解
Go 语言接口详解 核心概念 接口定义 在 Go 语言中,接口是一种抽象类型,它定义了一组方法的集合: // 定义接口 type Shape interface {Area() float64Perimeter() float64 } 接口实现 Go 接口的实现是隐式的: // 矩形结构体…...
oracle与MySQL数据库之间数据同步的技术要点
Oracle与MySQL数据库之间的数据同步是一个涉及多个技术要点的复杂任务。由于Oracle和MySQL的架构差异,它们的数据同步要求既要保持数据的准确性和一致性,又要处理好性能问题。以下是一些主要的技术要点: 数据结构差异 数据类型差异ÿ…...
RNN避坑指南:从数学推导到LSTM/GRU工业级部署实战流程
本文较长,建议点赞收藏,以免遗失。更多AI大模型应用开发学习视频及资料,尽在聚客AI学院。 本文全面剖析RNN核心原理,深入讲解梯度消失/爆炸问题,并通过LSTM/GRU结构实现解决方案,提供时间序列预测和文本生成…...
初学 pytest 记录
安装 pip install pytest用例可以是函数也可以是类中的方法 def test_func():print()class TestAdd: # def __init__(self): 在 pytest 中不可以使用__init__方法 # self.cc 12345 pytest.mark.api def test_str(self):res add(1, 2)assert res 12def test_int(self):r…...
使用Spring AI和MCP协议构建图片搜索服务
目录 使用Spring AI和MCP协议构建图片搜索服务 引言 技术栈概览 项目架构设计 架构图 服务端开发 1. 创建Spring Boot项目 2. 实现图片搜索工具 3. 配置传输模式 Stdio模式(本地调用) SSE模式(远程调用) 4. 注册工具提…...
MFC 抛体运动模拟:常见问题解决与界面美化
在 MFC 中开发抛体运动模拟程序时,我们常遇到 轨迹残留、无效刷新、视觉单调、物理逻辑瑕疵 等问题。本文将针对这些痛点,详细解析原因并提供解决方案,同时兼顾界面美化,让模拟效果更专业、更高效。 问题一:历史轨迹与小球残影残留 现象 小球运动后,历史位置的 “残影”…...
【C++进阶篇】智能指针
C内存管理终极指南:智能指针从入门到源码剖析 一. 智能指针1.1 auto_ptr1.2 unique_ptr1.3 shared_ptr1.4 make_shared 二. 原理三. shared_ptr循环引用问题三. 线程安全问题四. 内存泄漏4.1 什么是内存泄漏4.2 危害4.3 避免内存泄漏 五. 最后 一. 智能指针 智能指…...
