let_there_be_light
let_there_be_light

Reputation: 1007

Partition existing PostgreSQL table

I have a huge table (~500M rows), which I did not partition at the time of loading the data. If I create the partitions now, do I need to manually move the data from the master table to the child tables? Are there any better options.

Upvotes: 1

Views: 2458

Answers (1)

Troels
Troels

Reputation: 352

It is an old question, but what I have done and planned is to:

  1. rename the big table
  2. create a copy of the original table with include all (to get tablestructure, indexes, ect from the original table),
  3. partition the new table (I cant alter the table now by list (dont know why). c) Create partition tables by the list (example client_id) for each distinct value in the original table
  4. migrate the old table (with values) in the new partitioned table.
  5. Check data is in the new partitioned tables. If ok then
  6. delete old table.

Upvotes: 1

Related Questions