简体   繁体   English

Postgres 9.2中的垂直数据库分区

[英]vertical database partitioning in postgres 9.2

i have a table with 60 columns and want to vertically partition it, more or like dividing it in further small tables divided in columns. 我有一个包含60列的表格,想要垂直分区它,或者更多地将其划分为更多的按列划分的小表格。 how to do vertical partitioning in a database using postgres 9.2? 如何使用Postgres 9.2在数据库中进行垂直分区? did alot of google but couldnt find anything helpful. 做了很多谷歌,但找不到任何帮助。

table that i want to vertically partition is: 我要垂直分区的表是:

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");

thanks in advance 提前致谢

I don't think you are going to get a decent answer unless you specify why you want to vertically partition. 除非您指定为什么要垂直分区,否则我认为您不会得到一个不错的答案。 Sharding? 分片? Performance? 性能? Denormalizing? 非正规化? Only certain columns are necessary in the bulk of your queries? 您的大部分查询中仅需要某些列?

Somewhat related, if your dataset (uncompressed) in under 1TB, you can try Vertica's community edition for free, subject to their licensing restrictions (read the fine print). 有点相关,如果您的数据集(未压缩)在1TB以下,则可以根据其许可限制免费试用Vertica的社区版 (请阅读详细信息)。 Vertica is a columnar storage database and for many use-cases is remarkably fast. Vertica是一个列式存储数据库,对于许多用例来说,速度非常快。 I've used it in the past for analytics and it worked really well (there are some gotchas of course). 我过去曾将其用于分析,并且效果非常好(当然有些陷阱)。

Look for INSTEADOF Trigger. 查找INSTEADOF触发器。 Split the table with 2 different names and unify them throught a view. 用2个不同的名称拆分表,并在视图中统一它们。 Apply the instead of trigger on the view, and all inserts and deletes must be applicable to both tables. 在视图上应用而不是触发器,并且所有插入和删除操作都必须适用于两个表。 Look for handling updates carefully too 也希望仔细处理更新

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM