我试图尽可能详细地说明这一点。抱歉长度!
protein_snp_assoc我在 PostgreSQL(版本 12.13)数据库上创建了以下分区表:
CREATE TABLE protein_snp_assoc (
protein_id int not null,
snp_id int not null,
beta double precision,
se double precision,
logp double precision
) PARTITION BY RANGE (snp_id);
Run Code Online (Sandbox Code Playgroud)
然后,我根据以下模板创建了 51 个分区,每个分区包含大约 1.5 亿行(总共 76.5 亿行):
CREATE TABLE IF NOT EXISTS protein_snp_assoc_(x) PARTITION OF protein_snp_assoc
FOR VALUES FROM (y) TO (z);
Run Code Online (Sandbox Code Playgroud)
其中x范围从 1 到 51,并y, z定义间隔,每个长度为 150,000。例如,前两个和最后一个分区是:
protein_snp_assoc_1 FOR VALUES FROM (1) TO (150001),
protein_snp_assoc_2 FOR VALUES FROM (150001) TO (300001), ...
protein_snp_assoc_51 …Run Code Online (Sandbox Code Playgroud) postgresql database-design read-only-database query-performance postgresql-performance
postgresql ×1