小编Moh*_*eem的帖子

将 BIG 表上的列数据类型从 numeric(18, 2) 更改为 numeric(22, 6)

我们有一个非常大的POSTGRES表,包含超过80 亿行,并且以非常高的速度增长(每天 3000 万行)。

我们的表是按日期分区的。每个分区包含6 个月的数据,除了第一个分区包含近18 个月的数据。

Postgres 版本:PostgreSQL 12.11

数据库规格: db.r6g.16xlarge (vCPU:64,内存:512,EBSBandwidth(Mbps):19000)

表架构:

create table table_1
(
    id       bigint default nextval('table_1_id_seq'::regclass) not null,
    user_id  integer                                            not null,
    amount   numeric(18, 2)                                     not null,
    date     timestamp                                          not null,
    column_1 varchar                                            not null,
    column_2 varchar,
    .
    .
    primary key (id, date)
) partition by RANGE (date);
Run Code Online (Sandbox Code Playgroud)

该表还包含多个索引(包括部分索引

create index index_1
    on table_1 …
Run Code Online (Sandbox Code Playgroud)

postgresql datatypes alter-table postgresql-performance

7
推荐指数
1
解决办法
1780
查看次数