postgres 9.2中的垂直数据库分区

时间:2013-07-18 07:33:53

标签: postgresql vertical-partitioning

我有一个包含60列的表,想要对其进行垂直分区, 更多或者喜欢将它分成列中的更多小表。 如何使用postgres 9.2在数据库中进行垂直分区? 做了很多谷歌,但找不到任何有用的东西。

我要垂直分区的表是:

CREATE TABLE insurance.vt_owner
(
  regn_no character varying(10) NOT NULL,
  regn_dt timestamp without time zone,
  purchase_dt timestamp without time zone,
  owner_sr numeric(5,0),
  owner_name character varying(150),
  pan_no character varying(10),
  f_name character varying(150),
  c_add1 character varying(50),
  c_add2 character varying(50),
  c_city character varying(50),
  c_district character varying(30),
  c_pincode character varying(6),
  p_add1 character varying(50),
  p_add2 character varying(50),
  p_city character varying(50),
  p_district character varying(30),
  p_pincode character varying(6),
  owner_cd numeric(5,0),
  owner_cd_desc character varying(50),
  regn_type character varying(1),
  regn_type_desc character varying(50),
  vh_class numeric(5,0),
  vh_class_desc character varying(50),
  chasi_no character varying(30),
  eng_no character varying(30),
  maker numeric(5,0),
  maker_desc character varying(50),
  maker_model character varying(50),
  body_type character varying(3),
  body_type_desc character varying(50),
  no_cyl numeric(2,0),
  hp character varying(10),
  seat_cap numeric(3,0),
  stand_cap numeric(3,0),
  sleeper_cap numeric(2,0),
  unld_wt numeric(9,0),
  ld_wt numeric(9,0),
  fuel numeric(3,0),
  fuel_desc character varying(50),
  color character varying(50),
  manu_mon numeric(2,0),
  manu_yr numeric(4,0),
  fit_dt timestamp without time zone,
  norms numeric(2,0),
  norms_desc character varying(50),
  wheelbase character varying(10),
  cubic_cap character varying(10),
  floor_area numeric(7,3),
  ac_fiitted character(1),
  audio_fiitted character(1),
  video_fiitted character(1),
  vch_purchase_as character(1),
  vch_catg character(3),
  dealer_cd numeric(5,0),
  dealer_cd_desc character varying(50),
  sale_amt numeric(9,0),
  laser_code character varying(10),
  garage_add character varying(50),
  state_cd character varying(2) NOT NULL,
  rto_cd character varying(3) NOT NULL,
  CONSTRAINT vt_owner_pkey PRIMARY KEY (state_cd, rto_cd, regn_no)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE insurance.vt_owner
  OWNER TO postgres;

-- Index: insurance."index_VT_OWNER"

-- DROP INDEX insurance."index_VT_OWNER";

CREATE INDEX "index_VT_OWNER"
  ON insurance.vt_owner
  USING btree
  (regn_no COLLATE pg_catalog."default", chasi_no COLLATE pg_catalog."default", state_cd COLLATE pg_catalog."default", rto_cd COLLATE pg_catalog."default");

提前致谢

2 个答案:

答案 0 :(得分:1)

除非您指定为什么要垂直分区,否则我认为您不会得到合适的答案。拆分?性能?反规范化?您的大量查询中只需要某些列吗?

有点相关,如果您的数据集(未压缩)在1TB以下,您可以免费试用Vertica的community edition,但需遵守其许可限制(阅读细则)。 Vertica是一个柱状存储数据库,对于许多用例来说非常快。我过去曾用它来进行分析,而且效果非常好(当然还有一些问题)。

答案 1 :(得分:0)

寻找INSTEADOF触发器。将表拆分为2个不同的名称,并在视图中统一它们。在视图上应用而不是触发器,并且所有插入和删除都必须适用于两个表。也要仔细查看处理更新