java的获取pg分区表的api,Postgresql-9.5第三方分区表管理工具pg_partman测试

第三方分区表管理工具pg_partman。

[postgres@db2 ~] unzip pg_partman-2.6.2.zip

[postgres@db2 ~]cd pg_partman-2.6.2

[postgres@db2 ~] make install

[postgres@db2 ~]$ psql -d tank

psql (9.5.5)

Type "help" for help.

tank=# CREATE EXTENSION pg_partman;

CREATE EXTENSION

tank=#

tank=# CREATE TABLE ghan_x3

(

id int,

name char(10),

password text,

sales_date DATE NOT NULL DEFAULT CURRENT_DATE

);

tank=# create index ghan_x3_index on ghan_x3 (sales_date);

tank=# SELECT create_parent('public.ghan_x3', 'sales_date', 'time', 'monthly', p_premake := 20);

tank=# with dd as ( select generate_series(1,99900) as key,'ghan' ,md5(random()::text), date (NOW() + (random() * (NOW()+'365 days' - NOW())) + '1 days'

)) insert into ghan_x3 select * from dd;

tank=# select count(*) from ghan_x3 where sales_date < '2017-07-01' and sales_date >'2017-05-10';

count

-------

13737

(1 row)

tank=# explain select count(*) from ghan_x3 where sales_date < '2017-07-01' and sales_date >'2017-05-10';

QUERY PLAN

-----------------------------------------------------------------------------------------------------------

Aggregate  (cost=135.25..135.26 rows=1 width=0)

->  Append  (cost=0.00..135.09 rows=63 width=0)

->  Seq Scan on ghan_x3  (cost=0.00..0.00 rows=1 width=0)

Filter: ((sales_date < '2017-07-01'::date) AND (sales_date > '2017-05-10'::date))

->  Bitmap Heap Scan on ghan_x3_p2017_05  (cost=4.61..69.71 rows=32 width=0)

Recheck Cond: ((sales_date < '2017-07-01'::date) AND (sales_date > '2017-05-10'::date))

->  Bitmap Index Scan on ghan_x3_p2017_05_sales_date_idx  (cost=0.00..4.60 rows=32 width=0)

Index Cond: ((sales_date < '2017-07-01'::date) AND (sales_date > '2017-05-10'::date))

->  Bitmap Heap Scan on ghan_x3_p2017_06  (cost=4.59..65.38 rows=30 width=0)

Recheck Cond: ((sales_date < '2017-07-01'::date) AND (sales_date > '2017-05-10'::date))

->  Bitmap Index Scan on ghan_x3_p2017_06_sales_date_idx  (cost=0.00..4.58 rows=30 width=0)

Index Cond: ((sales_date < '2017-07-01'::date) AND (sales_date > '2017-05-10'::date))

(12 rows)

tank=#

更多功能请参考:

阅读(1603) | 评论(0) | 转发(0) |

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值