Re: Declarative Range Partitioning Postgres 11
От | Michael Lewis |
---|---|
Тема | Re: Declarative Range Partitioning Postgres 11 |
Дата | |
Msg-id | CAHOFxGqZtHphsNbAWJYWpBEyO0oSGuro0zCKWjir+kWbnFv+Aw@mail.gmail.com обсуждение исходный текст |
Ответ на | RE: Declarative Range Partitioning Postgres 11 (Shatamjeev Dewan <sdewan@nbsps.com>) |
Ответы |
RE: Declarative Range Partitioning Postgres 11
|
Список | pgsql-general |
On Fri, Nov 1, 2019 at 9:22 AM Shatamjeev Dewan <sdewan@nbsps.com> wrote:
Hi Michael,
I want to create a partition by year and subpartition by month in postgres 11 timestamp column. Please advise syntax.
The documentation is rather clear with examples like-
CREATE TABLE measurement_y2006m02 PARTITION OF measurement
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');
CREATE TABLE measurement_y2006m03 PARTITION OF measurement
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
CREATE TABLE measurement_y2006m03 PARTITION OF measurement
FOR VALUES FROM ('2006-03-01') TO ('2006-04-01');
Note- Don't partition on function results like date_part because performance will likely suffer greatly. Also note that the top end is always exclusive so the above give a continuous range for those two months.
I would hesitate to partition by more than year alone before upgrading to PG v12. The speed improvements for more than 10-100 partitions (max recommended for PG11) is huge in 12.
В списке pgsql-general по дате отправления: