我们有一个非常大的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)