PostgreSQL对象重组工具【pg_reorg】

pg_reorg是一个用于PostgreSQL数据库的重组工具,它在重组过程中不会阻塞读写操作。本文介绍了如何编译安装pg_reorg并引入为数据库扩展,然后通过测试案例展示了其在线CLUSTER、按指定列排序和在线VACUUM FULL等重组方法。同时,文章还提及了使用pg_reorg的限制,如不能重组临时表、GiST索引等,并提醒用户在执行pg_reorg时需要注意的事项。
摘要由CSDN通过智能技术生成


Description

pg_reorg is an utility program toreorganize tables in PostgreSQL databases. Unlike clusterdb, it doesn't blockany selections and updates during reorganization. You can choose one of thefollowing methods to reorganize.

 

  • Online CLUSTER (ordered by cluster index)

  • Ordered by specified columns

  • Online VACUUM FULL (packing rows only)

     

     

    NOTICE:

  • Only superusers can use the utility.

  • Target table must have PRIMARY KEY.

     

1、安装

编译安装

下载地址:http://pgfoundry.org/frs/?group_id=1000411&release_id=2083#pg_reorg-_1.1.10-title-content

 

[root@masterdb ~]# tar -zxvfpg_reorg-1.1.10.tar.gz

[root@masterdb ~]# cd pg_reorg-1.1.10

[root@masterdb pg_reorg-1.1.10]# ./home/postgres/.bash_profile

[root@masterdb pg_reorg-1.1.10]# make

[root@masterdb pg_reorg-1.1.10]# makeinstall

引入扩展

[postgres@masterdb ~]$ createdb tt

[postgres@masterdb ~]$ psql tt

psql (9.3.4)

Type "help" for help.

 

tt=# create extension pg_reorg ;

CREATE EXTENSION

tt=# \dx

                     List of installedextensions

  Name   | Version |   Schema  |            Description            

----------+---------+------------+------------------------------------

 pg_reorg | 1.1.10  | public    | re-organizes a PostgreSQL database

 plpgsql | 1.0     | pg_catalog | PL/pgSQLprocedural language

(2 rows)

 

 

2、测试

建立测试表

tt=# create table t1(id int primarykey,name text);

CREATE TABLE

tt=# insert into t1 select generate_series(1,5000000),'HighGo';

INSERT 0 5000000

tt=# \d+

                    List of relations

 Schema | Name | Type  | Owner   |  Size  | Description

--------+------+-------+----------+---------+-------------

 public | t1  | table | postgres | 211 MB  |

(1 row)

 

 

tt=# select pg_relation_filepath('t1');

 pg_relation_filepath

----------------------

 base/16812/16874

(1 row)

使用vacuum full

tt=# \timing

Timing is on.

tt=# vacuum FULL VERBOSE t1;

INFO: vacuuming "public.t1"

 

vacuum full

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值