1.创建分区表,并用generate_series(1,N)函数对表插入数据
create schema test;
create table test.p_tb1(
id int,name CHAR(30),store int)
partition by range (store)
(partition store_p0 values less than (60),
partition store_p1 values less than (70),
partition store_p2 values less than (80),
partition store_p3 values less than (90),
partition store_p4 values less than (10000));

insert into test.p_tb1
values(generate_series(10, 9999),
'ABS',
generate_series(10, 9999)
);
2.收集表统计信息
select relname, relpages, reltuples from pg_class where relname = 'p_tb1';

3.显示简单查询的执行计划;建立索引并显示有索引条件的执行计划
SET explain_perf_mode=normal;
EXPLAIN SELECT * FROM test.p_tb1;
create index p_tb1_idx on test.p_tb1(id);
EXPLAIN SELECT * FROM test.p_tb1 WHERE id<1000;
4.更新表数据,并做垃圾收集
update test.p_tb1 set id= id + 12 where id<1000;
VACUUM (VERBOSE, ANALYZE) test.p_tb1;
CHECKPOINT;


5.清理数据
drop schema test cascade;





