- uptimejp/pg_part
https://github.com/uptimejp/pg_part
- PostgreSQL: Documentation: 9.1: Partitioning
http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html
This extension contains five SQL functions so far: add_partition(), merge_partition(), attach_partition(), detach_partition() and show_partition()
For example, once add_partition() function is called, it executes several DDL commands implecitly within the SQL function to create a partition from the parent user table.
dbt3=# SELECT pgpart.add_partition( dbt3(# 'public', dbt3(# 'orders', dbt3(# 'orders_1992', dbt3(# ' ''1992-01-01'' <= o_orderdate AND o_orderdate < ''1993-01-01'' ', dbt3(# '/tmp/orders.tmp'); psql:add_part.sql:8: NOTICE: add_partition: CREATE TABLE public.orders_1992( CONSTRAINT __orders_1992_check CHECK( '1992-01-01' <= o_orderdate AND o_orderdate < '1993-01-01' )) INHERITS (public.orders); psql:add_part.sql:8: NOTICE: add_partition: COPY ( SELECT * FROM public.orders WHERE '1992-01-01' <= o_orderdate AND o_orderdate < '1993-01-01' ) to '/tmp/orders.tmp'; psql:add_part.sql:8: NOTICE: add_partition: DELETE FROM public.orders WHERE '1992-01-01' <= o_orderdate AND o_orderdate < '1993-01-01' ; psql:add_part.sql:8: NOTICE: add_partition: COPY public.orders_1992 FROM '/tmp/orders.tmp'; psql:add_part.sql:8: NOTICE: add_partition: ALTER TABLE public.orders_1992 ADD PRIMARY KEY (o_orderkey); psql:add_part.sql:8: NOTICE: add_partition: CREATE INDEX orders_1992_o_orderdate_idx ON public.orders_1992 USING btree (o_orderdate); psql:add_part.sql:8: NOTICE: add_partition: CREATE INDEX orders_1992_o_custkey_idx ON public.orders_1992 USING btree (o_custkey); add_partition --------------- t (1 row) dbt3=#
Please take a look, and if you have any question, comment, suggestion or request, feel free to tell me. Any feedback is welcome.
Enjoy!
No comments:
Post a Comment