本文主要采用list类型实现表分区,并对表分区数据进行查询对比,数据量6000万条以上,速度相差10倍以上。
一、创建表,以substationcode字段为ist类型表分区
CREATE TABLE "public"."d_population_partition" (
"sfzh" varchar(64) COLLATE "pg_catalog"."default" NOT NULL,
"hjdz" varchar(200) COLLATE "pg_catalog"."default",
"hsno" varchar(50) COLLATE "pg_catalog"."default",
"ldno" varchar(50) COLLATE "pg_catalog"."default",
"cno" varchar(50) COLLATE "pg_catalog"."default",
"birthday" timestamp(6),
"sex" varchar(10) COLLATE "pg_catalog"."default",
"name" varchar(100) COLLATE "pg_catalog"."default",
"type" varchar(10) COLLATE "pg_catalog"."default",
"keypersontype" varchar(10) COLLATE "pg_catalog"."default",
"gridcode" varchar(32) COLLATE "pg_catalog"."default",
"gridname" varchar(200) COLLATE "pg_catalog"."default",
"policestationcode" varchar(32) COLLATE "pg_catalog"."default",
"policestationname" varchar(200) COLLATE "pg_catalog"."default",
"substationcode" varchar(32) COLLATE "pg_catalog"."default",
"substationname" varchar(200) COLLATE "pg_catalog"."default",
"x