Work out partition count instantly with clear inputs, formula shown and shareable results.
Range partitioning by time is chosen for retention: dropping a partition is instant where deleting rows is not. The partition count then follows from the retention window and the interval, and it must be balanced against planning overhead, since query planners examine partition metadata and thousands of partitions slow every query even when pruning works.
Partition count
time-based: retention months x intervals per month; hash-based: ceil(total rows / target rows per partition)
PostgreSQL handles a few thousand but planning time grows; beyond that, consider a coarser interval or sub-partitioning. Measure planning time on your real queries.
Only when the partition key is in the predicate so pruning applies. Queries without it must touch every partition and often run slower than on an unpartitioned table.