我有一个按时间字段划分的表。我有 25 个分区。现在我考虑使用对象类型字段进一步对其进行分区。我有十个对象类型,所以它会产生 250 个分区。根据我阅读的内容,推荐的分区数是几十个,但在我的情况下,架构非常简单并且不包含任何连接,所以我想知道定义这么多分区是否可以。我正在使用 postgres 版本 9.1.2
CREATE TABLE metric_store.lc_aggregated_data_master_10_minutes
(
from_time integer,
object_id integer,
object_type integer,
latencies_client_fetch_sec_sum bigint,
latencies_client_rttsec_sum bigint,
latencies_db_bci_res_sec_sum bigint,
latencies_net_infrastructure_ttlb_sec_sum bigint,
latencies_retransmissions_sec_sum bigint,
latencies_ttfbsec_sum bigint,
latencies_ttlbsec_sum bigint,
latencies_ttlbsec_sumsqr bigint,
latencies_ttlbsec_histogram_level0 integer,
latencies_ttlbsec_histogram_level1 integer,
latencies_ttlbsec_histogram_level2 integer,
latencies_ttlbsec_histogram_level3 integer,
latencies_ttlbsec_histogram_level4 integer,
latencies_ttlbsec_histogram_level5 integer,
latencies_ttlbsec_histogram_level6 integer,
latencies_ttlbsec_histogram_level7 integer,
usage_bytes_total bigint,
usage_hits_total integer,
latencies_server_net_ttlbsec_sum bigint,
latencies_server_rttsec_sum bigint,
avaiability_errors_total integer
)
WITH (
OIDS=FALSE
);
ALTER TABLE metric_store.lc_aggregated_data_master_10_minutes
OWNER TO postgres;
CREATE TABLE metric_store.lc_aggregated_data_10_minutes_from_1353070800
(
CONSTRAINT lc_aggregated_data_10_minutes_from_1353070800_pkey PRIMARY KEY (from_time , object_id ),
CONSTRAINT lc_aggregated_data_10_minutes_from_1353070800_from_time_check CHECK (from_time >= 1353070800 AND from_time < 1353190800)
)
INHERITS (metric_store.lc_aggregated_data_master_10_minutes)
WITH (
OIDS=FALSE
);
ALTER TABLE metric_store.lc_aggregated_data_10_minutes_from_1353070800
OWNER TO postgres;
CREATE INDEX lc_aggregated_data_10_minutes_from_1353070800_obj_typ_idx
ON metric_store.lc_aggregated_data_10_minutes_from_1353070800
USING btree
(from_time , object_type );