README.md in pgslice-0.4.3 vs README.md in pgslice-0.4.4
- old
+ new
@@ -30,11 +30,11 @@
```sh
pgslice prep <table> <column> <period>
```
- Period can be `day` or `month`.
+ Period can be `day`, `month`, or `year`.
This creates a table named `<table>_intermediate` with the appropriate trigger for partitioning.
4. Add partitions
@@ -96,11 +96,11 @@
BEGIN;
CREATE TABLE visits_intermediate (LIKE visits INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING STORAGE INCLUDING COMMENTS) PARTITION BY RANGE (created_at);
-COMMENT ON TABLE visits_intermediate is 'column:created_at,period:day';
+COMMENT ON TABLE visits_intermediate is 'column:created_at,period:month';
COMMIT;
-- Postgres 9.6 and below
@@ -259,18 +259,21 @@
```sh
pgslice add_partitions <table> --future 3
```
-Add this as a cron job to create a new partition each day or month.
+Add this as a cron job to create a new partition each day, month, or year.
```sh
# day
0 0 * * * pgslice add_partitions <table> --future 3 --url ...
# month
0 0 1 * * pgslice add_partitions <table> --future 3 --url ...
+
+# year
+0 0 1 1 * pgslice add_partitions <table> --future 3 --url ...
```
Add a monitor to ensure partitions are being created.
```sql
@@ -281,14 +284,15 @@
WHERE
c.relkind = 'r' AND
n.nspname = 'public' AND
c.relname = '<table>_' || to_char(NOW() + INTERVAL '3 days', 'YYYYMMDD')
-- for months, use to_char(NOW() + INTERVAL '3 months', 'YYYYMM')
+ -- for years, use to_char(NOW() + INTERVAL '3 years', 'YYYY')
```
## Archiving Partitions
-Back up and drop older partitions each day or month.
+Back up and drop older partitions each day, month, or year.
```sh
pg_dump -c -Fc -t <table>_201609 $PGSLICE_URL > <table>_201609.dump
psql -c "DROP <table>_201609" $PGSLICE_URL
```