How many table partitions is too many in Postgres?

后端 未结 4 1922
攒了一身酷
攒了一身酷 2021-02-05 04:17

I\'m partitioning a very large table that contains temporal data, and considering to what granularity I should make the partitions. The Postgres partition documentation claims

4条回答
  •  自闭症患者
    2021-02-05 04:47

    "large numbers of partitions are likely to increase query planning time considerably" and recommends that partitioning be used with "up to perhaps a hundred" partitions.

    Because every extra partition will usually be tied to check constraints, and this will lead the planner to wonder which of the partitions need to be queried against. In a best case scenario, the planner identifies that you're only hitting a single partition and gets rid of the append step altogether.

    In terms of rows, and as DNS and Seth have pointed out, your milage will vary with the hardware. Generally speaking, though, there's no significant difference between querying a 1M row table and a 10M row table -- especially if your hard drives allow for fast random access and if it's clustered (see the cluster statement) using the index that you're most frequently hitting.

提交回复
热议问题