Re: Table performance with millions of rows (partitioning) - Mailing list pgsql-performance

From Robert Blayzor
Subject Re: Table performance with millions of rows (partitioning)
Date
Msg-id 47DA908F-BC21-45E6-8E30-73AFAC5F4853@inoc.net
Whole thread Raw
In response to Re: Table performance with millions of rows (partitioning)  (Justin Pryzby <pryzby@telsasoft.com>)
Responses Re: Table performance with millions of rows (partitioning)  (pinker <pinker@onet.eu>)
List pgsql-performance
On Dec 27, 2017, at 8:20 PM, Justin Pryzby <pryzby@telsasoft.com> wrote:
>
> That's one of the major use cases for partitioning (DROP rather than DELETE and
> thus avoiding any following vacuum+analyze).
> https://www.postgresql.org/docs/10/static/ddl-partitioning.html#DDL-PARTITIONING-OVERVIEW


That’s the plan to partition and I can easily change the code to insert directly into the child tables.

Right now, I was going to use date ranges (per month) based on a timestamp.

But could I just create 12 child tables, one for each month instead of creating one for Year+month ?

ie: instead of:

  (CHECK (ts >= DATE ‘2017-12-01' AND ts < DATE ‘2018-01-01’))

use:

  (CHECK (EXTRACT(MONTH FROM ts) = 12))


I’ll never need more than the least six months, so I’ll just truncate the older child tables. By the time the data
wrapsaround, the child table will be empty. 


I’m not even sure if the above CHECK (w/ EXTRACT) instead of just looking for a date range is valid.





pgsql-performance by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: Table performance with millions of rows (partitioning)
Next
From: pinker
Date:
Subject: Re: Table performance with millions of rows (partitioning)