Re: Partitioning an existing table - pg10.6

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Partitioning an existing table - pg10.6
Date: 2019-07-03 08:35:01
Message-ID: c3d8e3c1-db04-7b4f-561d-5e73f8c9e770@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/7/19 10:01 π.μ., Ayub M wrote:
> Hello, I am using postgres 10.6 and have a huge table with ~30m recs which needs to be partitioned. Whats the best strategy for it with minimal downtime?
>
> 1. Rename existing table and create new partitioned tables with orig name and keep inserting data from the old renamed to new table. This will incur downtime for the apps.
> 2. Create partitioned table with new name and move the data from current table (move oldest to newest) and when moving current month paritition shutdown down the app and move the last set of data.
> This will not incur downtime but if any data is changed which was already copied over then it might be lost.

Regarding 2) you could setup a trigger on the original table which would also replicate INSERTS, DELETES and UPDATES to the new table.

>
> Any other approaches/alternatives?
>
> --
> Regards,
> Ayub

--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

In response to

Browse pgsql-general by date

  From Date Subject
Next Message legrand legrand 2019-07-03 08:37:31 Re: Partitioning an existing table - pg10.6
Previous Message Vijaykumar Jain 2019-07-03 07:24:38 Re: [External] Re: multiple nodes in FDW create server statement