Skip to content

Commit

Permalink
Updating docs. Added Example to README file
Browse files Browse the repository at this point in the history
  • Loading branch information
keithf4 committed Sep 11, 2012
1 parent 59efeb1 commit cf3ef9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Still in early development, so not actually in extension format yet. Run install
cd pg_partman
psql < install.sql

EXAMPLE
-------

First create a parent table with an appropriate column type for the partitioning you will do. Here's one with a columns that can be used for either

CREATE schema test;
CREATE TABLE test.part_test (col1 serial, col2 text, col3 timestamptz DEFAULT now());

If you're looking to do time-based partitioning, and will only be inserting new data, time-static is an appropriate choice. Just run the create_parent() function with the appropriate parameters

SELECT part.create_parent('test.part_test', 'col3', 'time-static', 'daily');

This will turn your table into a parent table and premake 3 future partitions. To make new partitions for time-based partitioning, run the run_maintenance() function. Ideally, you'd run this as a cronjob to keep new partitions premade in preparation of new data.

This should be enough to get you started. Please see the partman.md file in the doc folder for more information on the types of partitioning supported and what the columns in the create_parent() function mean.

LICENSE AND COPYRIGHT
-------------------
Expand Down
6 changes: 3 additions & 3 deletions doc/pg_partman.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Extension to help make managing time or serial id based table partitioning easie
* Third column (p_type) is one of 4 values to set the partitioning type that will be used

> **time-static** - Trigger function inserts only into specifically named partitions (handles data for current partition, 2 partitions ahead and 1 behind). Cannot handle inserts to parent table outside the hard-coded time window. Function is kept up to date by run_maintenance() function. Ideal for high TPS tables that get inserts of new data only.
> **time-dynamic** - Trigger function can insert into any child partition based on the value of the control column. More flexible but not as efficient as time-static. Be aware that if the appropriate partition doesn't yet exist for the data inserted, the insert will fail. This applies for data before the lowest partition and higher than the greatest premade partition.
> **id-static** - Same functionality as time-static but for a numeric range instead of time. When the id value has reached 50% of the max value for that partition, it will automatically create the next partition in sequence if it doesn't yet exist. Does NOT require run_maintenance() function to be run separately.
> **id-dynamic** - Same functionality and limitations as time-dynamic but for a numeric range instead of time. Uses same 50% rule as id-static to create future partitions. Does NOT require run_maintenance() function to be run separately.
> **time-dynamic** - Trigger function can insert into any child partition based on the value of the control column. More flexible but not as efficient as time-static. Be aware that if the appropriate partition doesn't yet exist for the data inserted, the insert will fail. This applies for data before the lowest partition and higher than the greatest premade partition.
> **id-static** - Same functionality as time-static but for a numeric range instead of time. When the id value has reached 50% of the max value for that partition, it will automatically create the next partition in sequence if it doesn't yet exist. Does NOT require run_maintenance() function to create new partitions.
> **id-dynamic** - Same functionality and limitations as time-dynamic but for a numeric range instead of time. Uses same 50% rule as id-static to create future partitions. Does NOT require run_maintenance() function to create new partitions.
* Fourth parameter (p_interval) is the time or numeric range interval for each partition. Supported values are:

Expand Down

0 comments on commit cf3ef9a

Please sign in to comment.