小编Sep*_*rta的帖子

表分区与包含许多索引的非分区表

我有一个带有主表的数据库"DB_One",上面t_d_gate_out有8个索引.我创建了另一个带分区的数据库t_d_gate_out(让我们称之为"DB_Two").:它是由年份和月份(子表的例子分区t_d_gate_out09-2013有两个索引)(d _gate_out和每个孩子新列:i_trx_own)

这是我创建和插入子表的功能:

CREATE OR REPLACE FUNCTION ctm_test.gateout_partition_function()
  RETURNS trigger AS
$BODY$ 
DECLARE new_time text;
tablename text;
seqname text;
seqname_schema text;
bulantahun text;
bulan text;
bulan2 text;
tahun text;
enddate text;
result record;

BEGIN new_time := to_char(NEW.d_gate_out,'MM-YYYY');
bulan:=to_char(NEW.d_gate_out,'MM');
bulan2:=extract(month from NEW.d_gate_out);
tahun:=to_char(NEW.d_gate_out,'YYYY');
bulantahun := new_time;
tablename := 't_d_gate_out'||bulantahun;
seqname := 't_d_gate_out'||bulantahun||'_seq';
seqname_schema := 'ctm_test.t_d_gate_out'||bulantahun||'_seq';

PERFORM 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE 

c.relkind = 'r' AND …
Run Code Online (Sandbox Code Playgroud)

postgresql indexing partitioning postgresql-performance

5
推荐指数
1
解决办法
1916
查看次数