Recommendations on table partitioning

Gaurav Pant 0 Reputation points
2025-10-22T15:33:43.6266667+00:00

What are the recommended practices to move a table with a billion rows with multiple columns from a non-partitioned table to a partitioned table with minimal downtime in Azure PostgreSQL, few important related questions:

  1. How to decide the partition type and partition key?
  2. How to decide on the no.of partitions to be created?
  3. Estimate the time taken for such activity?
  4. How to speed up the partitioning activity?
  5. How to ensure minimum disruption in the running workload on the table getting partitioned, i.e. how to minimize time which affects DML commands to be run on the table.
Azure Database for PostgreSQL
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 39,376 Reputation points MVP Volunteer Moderator
    2025-10-22T16:34:33.2033333+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    There are many methods, the one advice on top of my mind. Let other experts pour in.

    Use range or list partitioning based on the most frequently filtered column (for ex: date, region, or category). The partition key should evenly distribute data and align with query patterns. Aim for 50 to 200 partitions, enough to manage performance without excessive metadata overhead.

    To migrate with minimal downtime, create a partitioned shadow table, bulk-insert data in parallel using INSERT ... SELECT or COPY, and use logical replication or triggers to sync incremental changes. Once caught up, swap tables in a short downtime window.

    Estimate time by sampling a subset load (for ex: the 1%) and extrapolating. To speed up, disable indexes and foreign keys during bulk load and re-enable afterward. Use parallelism and batch commits. Minimize disruption by performing the operation during off-peak hours and monitoring write latency.

    Please 'Upvote'(Thumbs-up) and 'Accept' as answer if the reply was helpful. This will be benefitting other community members who face the same issue.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.