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

From: Gabriel Sánchez <gabrielesanchez(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: How to query with more workers on a large table with many partitions
Date: 2026-04-01 14:56:20
Message-ID: CANHuRqH7q6bi7UAmW3w+o=11Sy1pzoY5KYsLfkpjS3X3T_OQHw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

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:

max_worker_processes = 12
max_parallel_workers_per_gather = 12
max_parallel_workers = 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gabriel Sánchez 2026-04-01 15:04:43 Speeding up ANALYZE on large partitioned tables
Previous Message Dominique Devienne 2026-04-01 07:53:55 Re: Any reason why PQclear() do not assign the pointer to NULL?