小编cc *_*ung的帖子

在 postgres 中,可以跨分区优化表吗?

在具有许多公司的数据库中,使用schemasearch_path

几乎所有访问都来自公司级别,即仅限于单个模式。一些数据仓库和会计功能需要扫描所有模式。

对于这个问题,根据@horse_with_no_name 的最佳建议,使用模式本身作为分区。例如

create table global.usr(
    usr_id int primary key,  // these will be unique across all partitions
    name varchar );

create table cmp1.usr(
    usr_id int primary key,
) inherits( global.usr );

create table cmp2.usr( 
    ....
Run Code Online (Sandbox Code Playgroud)

如果我们填充

insert into cmp1 usr values( 11, 'eleven' );
insert into cmp1 usr values( 12, 'twelve' );

insert into cmp2 usr values( 21, 'twenty-one' );
insert into cmp2 usr values( 22, 'twenty-two' );

insert into cmp3 usr values( 31, 'thirty-one' …
Run Code Online (Sandbox Code Playgroud)

postgresql

6
推荐指数
1
解决办法
503
查看次数

标签 统计

postgresql ×1