首页 > 其他分享 >pg_squeeze使用

pg_squeeze使用

时间:2022-12-05 09:34:59浏览次数:32  
标签:rhel7 x86 64 pg 使用 squeeze postgres

 

1.查看相关的版本
需要提前安装pg的yum

[root@localhost]#yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
[root@localhost]#yum install epel-release
[root@localhost pg_wal]# yum list pg_squeeze*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * epel: hkg.mirror.rackspace.com
 * extras: mirrors.njupt.edu.cn
 * updates: mirrors.ustc.edu.cn
Available Packages
pg_squeeze10.x86_64                                            1.3.0-1.rhel7                                   pgdg10
pg_squeeze11.x86_64                                            1.3.0-1.rhel7                                   pgdg11
pg_squeeze12.x86_64                                            1.3.0-1.rhel7                                   pgdg12
pg_squeeze13.x86_64                                            1.3.0-1.rhel7                                   pgdg13
pg_squeeze_10.x86_64                                           1.4.1-2.rhel7                                   pgdg10
pg_squeeze_11.x86_64                                           1.5.0-1.rhel7                                   pgdg11
pg_squeeze_11-llvmjit.x86_64                                   1.5.0-1.rhel7                                   pgdg11
pg_squeeze_12.x86_64                                           1.5.0-1.rhel7                                   pgdg12
pg_squeeze_12-llvmjit.x86_64                                   1.5.0-1.rhel7                                   pgdg12
pg_squeeze_13.x86_64                                           1.5.0-1.rhel7                                   pgdg13
pg_squeeze_13-llvmjit.x86_64                                   1.5.0-1.rhel7                                   pgdg13
pg_squeeze_14.x86_64                                           1.5.0-1.rhel7                                   pgdg14
pg_squeeze_14-llvmjit.x86_64                                   1.5.0-1.rhel7                                   pgdg14
pg_squeeze_15.x86_64                                           1.5.0-1.rhel7                                   pgdg15
pg_squeeze_15-llvmjit.x86_64                                   1.5.0-1.rhel7                                   pgdg15

 

2.安装
[root@localhost]# yum install pg_squeeze12.x86_64

3.添加扩展
su - postgres
vi /opt/pg12/data/postgresql.conf

shared_preload_libraries = 'pg_repack,pg_squeeze' # (change requires restart)

重新启动pg
[root@localhost ~]# systemctl stop postgresql-12
[root@localhost ~]# systemctl start postgresql-12

 

4.添加插件

postgres=# create extension pg_squeeze;
CREATE EXTENSION

postgres=# \dn
    List of schemas
    Name    |  Owner   
------------+----------
 public     | postgres
 repack     | postgres
 squeeze    | postgres
 tiger      | postgres
 tiger_data | postgres
 topology   | postgres
(6 rows)

 

这个时候会生成一个schema=squeeze,有如下的表

postgres=# set search_path to 'squeeze';
SET
postgres=# \dt
              List of relations
 Schema  |      Name       | Type  |  Owner   
---------+-----------------+-------+----------
 squeeze | errors          | table | postgres
 squeeze | log             | table | postgres
 squeeze | tables          | table | postgres
 squeeze | tables_internal | table | postgres
 squeeze | tasks           | table | postgres
(5 rows)

 

5.创建测试表
postgres=# create table test(id int primary key);
postgres=# insert into test select generate_series(1,5000000);

查看表的大小
postgres=# SELECT pg_size_pretty(pg_total_relation_size('test'));
pg_size_pretty
----------------
280 MB
(1 row)

6.向squeeze.tables插入一条数据,定期清理test表,5分钟一次
insert into squeeze.tables (tabschema, tabname, schedule, free_space_extra) values ('public', 'test', ('{00,59}', '{00,23}', NULL, NULL, NULL), '10');

7.启动pg_squeeze的进程需要调用
SELECT squeeze.start_worker();
关闭命令:SELECT squeeze.stop_worker();

8.查看当前表的膨胀情况
select * from squeeze.tables_internal;


此时test表大小

postgres=# \dt+ test;
List of relations
Schema | Name | Type | Owner | Size | Description
--------+------+-------+----------+--------+-------------
public | test | table | postgres | 173 MB |
(1 row)


9.删除test表一半数据
postgres=# delete from test where id < 2500000;
DELETE 2499999

再次查看表的膨胀情况
select * from squeeze.tables_internal;

 

-- The End --

 

标签:rhel7,x86,64,pg,使用,squeeze,postgres
From: https://www.cnblogs.com/hxlasky/p/16951464.html

相关文章

  • 懒人听书下载文件被加密?使用这个工具一键解决!
    直接通过懒人听书上下载的声音是经过加密的,没办法通过其他播放器进行播放,也没法进行声音文件分享给其他小伙伴。 如果不懂电脑技术,是没办法进行解密的,不过有个工具帮我......
  • 重复使用一个路由组件而不同路径遇到的周期函数触发问题
    最近在开发Vue3项目的时候,因为业务需要,存在两个页面布局、逻辑等差不多的页面,本着偷懒......
  • 【CTF工具】windows上使用binwalk工具(转载)
    基础配置基础环境需要python3,下载地址为:https://www.python.org/downloads/windows/binwalk下载地址:https://github.com/ReFirmLabs/binwalk工具安装安装binwalk命......
  • 智能合约库-OpenZeppelin使用
    官网:​​https://www.openzeppelin.com/​​GitHub:​​https://github.com/OpenZeppelin/openzeppelin-contracts​​OpenZeppelin是一个使用Ethereum智能合约语言Solidit......
  • 在C#中使用Irony实现SQL语句的解析
    https://sunnycoding.cn/2019/07/11/sql-parser-with-irony-in-csharp/ 本文结构定义语法语法测试语句解析获得解析结果总结在上一篇博文中,我介绍了LOGO语言的C......
  • 使用ShardingCore分表
    项目环境:ABP+Mysql 一、准备一个ABP项目这里采用ABP的Samples中的一个样板项目TodoApp下的Mvc-EfCore下载地址:https://github.com/abpframework/abp-samples/tree/......
  • 远程桌面 ubuntu20使用vnc访问
     1ubuntu20开发端口安装端口管理软件sudoapt-getinstallufw关闭所有端口(如果你知道vnc都用了哪些端口,直接开发对应的,尤其是局域网端口)sudoufwdisable查看防......
  • MongoDB 的使用
    MongoDB的使用mongoDB的常见命令使用;MongoDB默认在27017端口上运行;1.常见命令#进入交互终端mongo开启云监控平台//开启云监控平台[公司一般不会允许内部信......
  • 使用torch pruning工具进行结构化剪枝
    网络结构定义importtorchimporttorch.nnasnnimporttorch.nn.functionalasFimporttorch_pruningastpfromtorchvision.datasetsimportCIFAR10fromtorchv......
  • Python 使用MongoDB & MongoDB 工具的封装
    Python使用MongoDB补充:操作之前首先在虚拟机或者服务器端启动MongoDB;#重新加载配置,并启动mongodbsudosystemctldaemon-reloadsudosystemctlstartmongod#......