How to query with more workers on a large table with many partitions

  • Jump to comment-1
    Gabriel Sánchez<gabrielesanchez@gmail.com>
    Apr 1, 2026, 2:56 PM UTC
    Hi PostgreSQL community,
    I have a large table (86 GB) that is declaratively partitioned by year,
    sub-partitioned by month, and sub-sub-partitioned by day. It currently has
    437 leaf partitions, and will continue to grow with a new partition each
    day. When I query a simple count(*) by date, the query planner plans a
    query with five workers, but I have the following in postgresql.conf:
    maxworkerprocesses = 12
    maxparallelworkerspergather = 12
    maxparallelworkers = 12
    shared_buffers = 32GB
    temp_buffers = 1GB
    work_mem = 512MB
    The top-level partitioned table has been ANALYZEd.
    I'm running PostgreSQL 16 on an AWS EC2 instance with 16 logical processors
    and 128G of RAM. How can I get PG to run the query with more workers?
    Thank you,
    Gabriel
    • Jump to comment-1
      Greg Hennessy<greg.hennessy@gmail.com>
      Apr 1, 2026, 3:05 PM UTC
      I'm running PostgreSQL 16 on an AWS EC2 instance with 16 logical > processors and 128G of RAM. How can I get PG to run the query with > more workers?
      Postgres allocates more workers based on the log3 of the ratio of the table size to minparalleltablescansize.
      You may want to try |ALTER TABLE ... SET (parallel_workers = 10) (or whatever your desired value is).
      |