Skip to content

Commit 37c7a4d

Browse files
committed
new doc
1 parent a1454e9 commit 37c7a4d

File tree

8 files changed

+213
-3
lines changed

8 files changed

+213
-3
lines changed

202307/20230710_03.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,11 @@ git clone --depth 1 https://github.com/andrielfn/pg-ulid.git
13841384
cd $TEMP_DIR/pg-ulid
13851385
USE_PGXS=1 make install
13861386
1387+
cd $TEMP_DIR
1388+
git clone --depth 1 https://github.com/phillbaker/pg_migrate.git
1389+
cd $TEMP_DIR/pg_migrate/
1390+
USE_PGXS=1 make install
1391+
13871392
cd /usr/lib/postgresql/14
13881393
git clone --depth 1 https://github.com/swida/sqlbench
13891394
cd /usr/lib/postgresql/14/sqlbench
@@ -1865,7 +1870,8 @@ docker run --platform linux/amd64 -d -it -P --cap-add=SYS_PTRACE --cap-add SYS_A
18651870
- pg_stats_reporter, pg_statsinfo报告的网页呈现, 更加美观, 类似awr效果.
18661871
- pgtelemetry, 一些DBA常用的监控数据库和操作系统运行状态的视图.
18671872
- pgfincore, 修改数据文件的page cache行为
1868-
- repack, 几乎不影响业务的收缩膨胀的表和索引浪费的存储空间
1873+
- pg_repack, 几乎不影响业务的收缩膨胀的表和索引浪费的存储空间
1874+
- pg_migrate, online DDL, fork自pg_repack, 实现最短时间持有排他锁的DDL, DDL过程中支持DML.
18691875
- squeeze, 几乎不影响业务的收缩膨胀的表和索引浪费的存储空间, 支持设置阈值, 自动调度.
18701876
- pgagent, 定时任务
18711877
- pg_cron, 定时任务

202308/20230814_02.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,11 @@ git clone --depth 1 https://github.com/andrielfn/pg-ulid.git
10301030
cd $TEMP_DIR/pg-ulid
10311031
USE_PGXS=1 make install
10321032
1033+
cd $TEMP_DIR
1034+
git clone --depth 1 https://github.com/phillbaker/pg_migrate.git
1035+
cd $TEMP_DIR/pg_migrate/
1036+
USE_PGXS=1 make install
1037+
10331038
cd /usr/lib/postgresql/14
10341039
git clone --depth 1 https://github.com/swida/sqlbench
10351040
cd /usr/lib/postgresql/14/sqlbench

202401/20240104_01.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,27 @@ Reviewed-by: Peter Smith, Masahiko Sawada, Michael Paquier, Amit Kapila, Hayato
6464
Discussion: https://postgr.es/m/20230217075433.u5mjly4d5cr4hcfe@jrouhaud
6565
```
6666

67+
68+
#### [期望 PostgreSQL|开源PolarDB 增加什么功能?](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216")
69+
70+
71+
#### [PolarDB 开源数据库](https://openpolardb.com/home "57258f76c37864c6e6d23383d05714ea")
72+
73+
74+
#### [PolarDB 学习图谱](https://www.aliyun.com/database/openpolardb/activity "8642f60e04ed0c814bf9cb9677976bd4")
75+
76+
77+
#### [购买PolarDB云服务折扣活动进行中, 55元起](https://www.aliyun.com/activity/new/polardb-yunparter?userCode=bsb3t4al "e0495c413bedacabb75ff1e880be465a")
78+
79+
80+
#### [PostgreSQL 解决方案集合](../201706/20170601_02.md "40cff096e9ed7122c512b35d8561d9c8")
81+
82+
83+
#### [德哥 / digoal's Github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae")
84+
85+
86+
#### [About 德哥](https://github.com/digoal/blog/blob/master/me/readme.md "a37735981e7704886ffd590565582dd0")
87+
88+
89+
![digoal's wechat](../pic/digoal_weixin.jpg "f7ad92eeba24523fd47a6e1a0e691b59")
90+

202401/20240104_02.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,27 @@ Arrow_Fdw 会跳过 ymd 字段的最大值小于 的 `record-batch` `'2020-01-0
111111
- PG-Strom v5.0 停止支持 PostgreSQL v14 或更早版本。计划版本为 v15 或更高版本。
112112
- 由于开发进度原因,v5.0 禁用了分区方式的 GpuJoin。它将在不久的将来版本中重新实现。
113113

114+
115+
#### [期望 PostgreSQL|开源PolarDB 增加什么功能?](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216")
116+
117+
118+
#### [PolarDB 开源数据库](https://openpolardb.com/home "57258f76c37864c6e6d23383d05714ea")
119+
120+
121+
#### [PolarDB 学习图谱](https://www.aliyun.com/database/openpolardb/activity "8642f60e04ed0c814bf9cb9677976bd4")
122+
123+
124+
#### [购买PolarDB云服务折扣活动进行中, 55元起](https://www.aliyun.com/activity/new/polardb-yunparter?userCode=bsb3t4al "e0495c413bedacabb75ff1e880be465a")
125+
126+
127+
#### [PostgreSQL 解决方案集合](../201706/20170601_02.md "40cff096e9ed7122c512b35d8561d9c8")
128+
129+
130+
#### [德哥 / digoal's Github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae")
131+
132+
133+
#### [About 德哥](https://github.com/digoal/blog/blob/master/me/readme.md "a37735981e7704886ffd590565582dd0")
134+
135+
136+
![digoal's wechat](../pic/digoal_weixin.jpg "f7ad92eeba24523fd47a6e1a0e691b59")
137+

202401/20240104_03.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,27 @@ Reviewed-by: Amit Kapila, Bertrand Drouvot, Michael Paquier
5656
Discussion: https://postgr.es/m/[email protected]
5757
```
5858

59+
60+
#### [期望 PostgreSQL|开源PolarDB 增加什么功能?](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216")
61+
62+
63+
#### [PolarDB 开源数据库](https://openpolardb.com/home "57258f76c37864c6e6d23383d05714ea")
64+
65+
66+
#### [PolarDB 学习图谱](https://www.aliyun.com/database/openpolardb/activity "8642f60e04ed0c814bf9cb9677976bd4")
67+
68+
69+
#### [购买PolarDB云服务折扣活动进行中, 55元起](https://www.aliyun.com/activity/new/polardb-yunparter?userCode=bsb3t4al "e0495c413bedacabb75ff1e880be465a")
70+
71+
72+
#### [PostgreSQL 解决方案集合](../201706/20170601_02.md "40cff096e9ed7122c512b35d8561d9c8")
73+
74+
75+
#### [德哥 / digoal's Github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae")
76+
77+
78+
#### [About 德哥](https://github.com/digoal/blog/blob/master/me/readme.md "a37735981e7704886ffd590565582dd0")
79+
80+
81+
![digoal's wechat](../pic/digoal_weixin.jpg "f7ad92eeba24523fd47a6e1a0e691b59")
82+

202401/20240104_04.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
## 用pg_migrate实现PostgreSQL online DDL with table rewrite
2+
3+
### 作者
4+
digoal
5+
6+
### 日期
7+
2024-01-04
8+
9+
### 标签
10+
PostgreSQL , PolarDB , DuckDB , online DDL , 排他锁 , pg_migrate , pg_repack
11+
12+
----
13+
14+
## 背景
15+
16+
https://github.com/phillbaker/pg_migrate
17+
18+
pg_migrate is a PostgreSQL extension and CLI which lets you make schema changes to tables and indexes. Unlike ALTER TABLE it works online, without holding a long lived exclusive lock on the processed tables during the migration. It builds a copy of the target table and swaps them.
19+
20+
Forked from the excellent pg_repack project (https://reorg.github.io/pg_repack).
21+
22+
## Examples
23+
Change the type of a column
24+
```
25+
pg_migrate --table=my_table --alter='ALTER COLUMN id TYPE bigint' # Add --execute to run
26+
```
27+
28+
Add a column with a default (non-nullable)
29+
```
30+
pg_migrate --table=my_table --alter='ADD COLUMN foo integer NOT NULL DEFAULT 42' # Add --execute to run
31+
```
32+
33+
## Known Limitations
34+
- Unique constraints are converted into unique indexes, they are equivalent in Postgres. However, this may be an unexpected change.
35+
- Index names on the target table and foreign key constraints are changed during the migration.
36+
- If the generated names are > 63 characters, this will likely break
37+
- If the target table is used in views, those objects will continue to reference the original table - this is not supported currently.
38+
- If the target table is used in stored procedures, those functions are stored as text so are not linked through object IDs and will reference the migrated table.
39+
- DDL to drop columns or add columns without a default is not currently supported
40+
- Hosted PG databases (RDS, Cloud SQL) are not supported because they do not allow installing custom extensions.
41+
42+
43+
## Demo
44+
```
45+
cd /tmp
46+
git clone --depth 1 https://github.com/phillbaker/pg_migrate
47+
cd pg_migrate/
48+
USE_PGXS=1 make install
49+
```
50+
51+
```
52+
root@56000550f873:/tmp/pg_migrate# psql
53+
psql (14.10 (Debian 14.10-1.pgdg110+1))
54+
Type "help" for help.
55+
56+
postgres=# create extension pg_migrate ;
57+
CREATE EXTENSION
58+
postgres=# \q
59+
```
60+
61+
```
62+
root@56000550f873:/tmp/pg_migrate# pg_migrate --help
63+
pg_migrate migrates a PostgreSQL table avoiding long locks.
64+
65+
Usage:
66+
pg_migrate [OPTION]... [DBNAME]
67+
Options:
68+
-t, --table=TABLE table to target
69+
-d, --database=DATABASE database in which the table lives
70+
-s, --tablespace=TBLSPC move table to a new tablespace
71+
-a, --alter=ALTER SQL of the alter statement
72+
-N, --execute whether to run the migration
73+
-j, --jobs=NUM Use this many parallel jobs for each table
74+
-T, --wait-timeout=SECS timeout to cancel other backends on conflict
75+
-D, --no-kill-backend don't kill other backends when timed out
76+
-k, --no-superuser-check skip superuser checks in client
77+
78+
Connection options:
79+
-d, --dbname=DBNAME database to connect
80+
-h, --host=HOSTNAME database server host or socket directory
81+
-p, --port=PORT database server port
82+
-U, --username=USERNAME user name to connect as
83+
-w, --no-password never prompt for password
84+
-W, --password force password prompt
85+
86+
Generic options:
87+
-e, --echo echo queries
88+
-E, --elevel=LEVEL set output message level
89+
--help show this help, then exit
90+
--version output version information, then exit
91+
92+
Read the website for details: <https://github.com/phillbaker/pg_migrate>.
93+
Report bugs to <https://github.com/phillbaker/pg_migrate/issues>.
94+
```
95+
96+
97+
#### [期望 PostgreSQL|开源PolarDB 增加什么功能?](https://github.com/digoal/blog/issues/76 "269ac3d1c492e938c0191101c7238216")
98+
99+
100+
#### [PolarDB 开源数据库](https://openpolardb.com/home "57258f76c37864c6e6d23383d05714ea")
101+
102+
103+
#### [PolarDB 学习图谱](https://www.aliyun.com/database/openpolardb/activity "8642f60e04ed0c814bf9cb9677976bd4")
104+
105+
106+
#### [购买PolarDB云服务折扣活动进行中, 55元起](https://www.aliyun.com/activity/new/polardb-yunparter?userCode=bsb3t4al "e0495c413bedacabb75ff1e880be465a")
107+
108+
109+
#### [PostgreSQL 解决方案集合](../201706/20170601_02.md "40cff096e9ed7122c512b35d8561d9c8")
110+
111+
112+
#### [德哥 / digoal's Github - 公益是一辈子的事.](https://github.com/digoal/blog/blob/master/README.md "22709685feb7cab07d30f30387f0a9ae")
113+
114+
115+
#### [About 德哥](https://github.com/digoal/blog/blob/master/me/readme.md "a37735981e7704886ffd590565582dd0")
116+
117+
118+
![digoal's wechat](../pic/digoal_weixin.jpg "f7ad92eeba24523fd47a6e1a0e691b59")
119+

202401/readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
### 文章列表
44
----
5-
##### 20240103_02.md [《用递归模拟SEMI-JOIN性能提升1325倍》](20240103_02.md)
5+
##### 20240104_04.md [《用pg_migrate实现PostgreSQL online DDL with table rewrite》](20240104_04.md)
6+
##### 20240104_03.md [《PostgreSQL 17 preview - 主库视图 `pg_replication_slots`.`conflict_reason` 支持逻辑复制冲突原因跟踪》](20240104_03.md)
7+
##### 20240104_02.md [《PostgreSQL 利用GPU加速OLAP的插件pg-strom发布5.0版本》](20240104_02.md)
8+
##### 20240104_01.md [《PostgreSQL 17 preview - pg_upgrade大版本升级支持保留逻辑订阅全部信息 (preserve the full subscription's state)》](20240104_01.md)
9+
##### 20240103_02.md [《用递归模拟SEMI-JOIN性能提升921倍》](20240103_02.md)
610
##### 20240103_01.md [《PostgreSQL 获得2023年度数据库, 和你我有什么关系?》](20240103_01.md)
711
##### 20240102_02.md [《facechain, 开源数字人形象的深度学习模型工具》](20240102_02.md)
812
##### 20240102_01.md [《体验MotherDuck读写阿里云OSS》](20240102_01.md)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ digoal's|PostgreSQL|文章|归类
9797

9898
### 所有文档如下
9999
----
100-
##### 202401/20240103_02.md [《用递归模拟SEMI-JOIN性能提升1325倍》](202401/20240103_02.md)
100+
##### 202401/20240104_04.md [《用pg_migrate实现PostgreSQL online DDL with table rewrite》](202401/20240104_04.md)
101+
##### 202401/20240104_03.md [《PostgreSQL 17 preview - 主库视图 `pg_replication_slots`.`conflict_reason` 支持逻辑复制冲突原因跟踪》](202401/20240104_03.md)
102+
##### 202401/20240104_02.md [《PostgreSQL 利用GPU加速OLAP的插件pg-strom发布5.0版本》](202401/20240104_02.md)
103+
##### 202401/20240104_01.md [《PostgreSQL 17 preview - pg_upgrade大版本升级支持保留逻辑订阅全部信息 (preserve the full subscription's state)》](202401/20240104_01.md)
104+
##### 202401/20240103_02.md [《用递归模拟SEMI-JOIN性能提升921倍》](202401/20240103_02.md)
101105
##### 202401/20240103_01.md [《PostgreSQL 获得2023年度数据库, 和你我有什么关系?》](202401/20240103_01.md)
102106
##### 202401/20240102_02.md [《facechain, 开源数字人形象的深度学习模型工具》](202401/20240102_02.md)
103107
##### 202401/20240102_01.md [《体验MotherDuck读写阿里云OSS》](202401/20240102_01.md)

0 commit comments

Comments
 (0)