Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubj8l-004TPZ-3k for pgsql-general@arkaria.postgresql.org; Tue, 15 Jul 2025 17:08:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ubj8j-003kKc-7J for pgsql-general@arkaria.postgresql.org; Tue, 15 Jul 2025 17:08:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ubj8i-003kKS-Sk for pgsql-general@lists.postgresql.org; Tue, 15 Jul 2025 17:08:25 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ubj8h-007uXs-0z for pgsql-general@lists.postgresql.org; Tue, 15 Jul 2025 17:08:24 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5551a770828so5806266e87.1 for ; Tue, 15 Jul 2025 10:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752599302; x=1753204102; darn=lists.postgresql.org; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=xpkzlGqTkRDz5c5E12d/V0AdMQSHjG5TGodawZ/3LSQ=; b=jpqPG4DRGXxZGnQsg0SjW1LBGvGHqub/kR7VgDlvcTilRgADTpL0jcEjQP8lGA9+yq 4vtXieq9wEjC2zEOdN7/U71hRe8bIXYWsLLGXvjW/wuZFLde+BiBBx4ixGmoojBXECIp Lmi93Gw60eBMerjs/Lkz4Fq0Zwi8hgPXdDvA+mVH3Cj8ULCdGhB4bf9V41j85aQkI9Lq whzB8x29jXzJzkDSQo4D5/2KtA4UfOFSvfA953TqSIA9pKVtQ8Ou2exl05qjy8r61Rgy 4K2bwZiYszR0XMPT1p2A7UCzaNy9TRRxVX427e+fKPd4b3SRJ62oFbdVpIKd39MJWpoA QM0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752599302; x=1753204102; h=cc:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xpkzlGqTkRDz5c5E12d/V0AdMQSHjG5TGodawZ/3LSQ=; b=JIyG5HXe6qO7+PkeptlLjRZAdsDUNUtsiFncwsWguckGJ6pxsJemwYSgNTQCigw1Ks xratRrB3eCbWi65cMTLLZybUuedulzRsPvtqj5Ax8MO1xkZ6hdQmVxMjuwSX94y6nUzo KIUAuNtBA87uQJCuepmaS4pYd0K7BhcVLyFkNz4GqdkFafeqj4uZHOc7Gl5XNnfNcSw/ xNU0+rkiHvSo5Wue6iDpgdvAp8FinFIyXVWD3pxNcOCOoCZ9vQnN+jEjLpO3LVg/jyEg wHkpbEw0HV7e0O5FKYkkTaTSmI9sNpt6ATPZDWRQPn8BrvmZx1eTJ7k+6BN4lb3Ls6gO YJEQ== X-Gm-Message-State: AOJu0YzxiHeXgEm03uRQSmzodX3gASKrfF5NswrHFEcoU7EQUYpf7EBN Iy1g1SdYOV4HrVOwha6a9/wnjs+y7B3D/dnOwY6uOAF7nBtxD414ernR7hBCr6b09TnD+FEzktz wdc8dvGYDbH+bG+FEqvYzz6j/3fJHFSYauA== X-Gm-Gg: ASbGncvmQbT1BPBL/2MPMjQ+inKfSU7LnEM7cMcLcC/qH01t8WR0liHA3pD3JciZH9n S8yXnLEW7p4nCiyNK2g5JSe4Nt8kWQqTVoM6F7WQMWxXeDRtM1qLM5AquAS8Tgm/pma+FJLxflc 6DSVGsnsaKHrEQkk6vX2cBALgBRaCziQaIrpJTumY9Wkbl6X4/OAGGAk9A1HtveFD7vB+AQOlT9 3yG5A== X-Google-Smtp-Source: AGHT+IFkybCt/1xj9i608PZVlz7VwrbRED2NbSoyPnQBNIIAJBhRfGrT7En1wA/KtoX7eG3UMHw+9gPOkKWRtlOys1Y= X-Received: by 2002:a05:6512:e8d:b0:553:338d:c4 with SMTP id 2adb3069b0e04-55a233f7891mr68499e87.56.1752599301567; Tue, 15 Jul 2025 10:08:21 -0700 (PDT) MIME-Version: 1.0 References: <710283.1752519282@sss.pgh.pa.us> In-Reply-To: <710283.1752519282@sss.pgh.pa.us> From: Greg Hennessy Date: Tue, 15 Jul 2025 13:07:44 -0400 X-Gm-Features: Ac12FXyx3FocdcgDmvl6KOzQjwnNJqROdxZsr9ZmJ8LYQHIAPqjvtZXcJlzsn3o Message-ID: Subject: Re: optimizing number of workers Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000cdbced0639fad2f1" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000cdbced0639fad2f1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable if I "alter table allwise set (parallel_workers =3D 64);" then I can get 64 workers. I wonder if the code to check the rel_parallel_workers do deal with the default algorithm not allocating sufficient parallel_workers. On Mon, Jul 14, 2025 at 2:54=E2=80=AFPM Tom Lane wrote: > Greg Hennessy writes: > >> Postgres has chosen to use only a small fraction of the CPU's I have o= n > >> my machine. Given the query returns an answer in about 8 seconds, it > may be > >> that Postgresql has allocated the proper number of works. But if I > wanted > >> to try to tweak some config parameters to see if using more workers > >> would give me an answer faster, I don't seem to see any obvious knobs > >> to turn. Are there parameters that I can adjust to see if I can increa= se > >> throughput? Would adjusting parallel_setup_cost or parallel_tuple_cost > >> likely to be of help? > > See the bit about > > * Select the number of workers based on the log of the size = of > * the relation. This probably needs to be a good deal more > * sophisticated, but we need something here for now. Note > that > > in compute_parallel_worker(). You can move things at the margins by > changing min_parallel_table_scan_size, but that logarithmic behavior > will constrain the number of workers pretty quickly. You'd have to > change that code to assign a whole bunch of workers to one scan. > > (No, I don't know why it's done like that. There might be related > discussion in our archives, but finding it could be difficult.) > > regards, tom lane > --000000000000cdbced0639fad2f1 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
if I "alter table allwise set (parallel_workers =3D 6= 4);" then I can get 64 workers. I wonder if the code
to check the = rel_parallel_workers do deal with the default algorithm not allocating suff= icient
parallel_workers.


On Mon, Jul 14, 2025 at 2:54=E2=80=AFPM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Greg Hennessy <greg.hennessy@gmail.com> write= s:
>> Postgres has chosen to use only a small fraction of the CPU's = I have on
>> my machine. Given the query returns an answer in about 8 seconds, = it may be
>> that Postgresql has allocated the proper number of works. But if I= wanted
>> to try to tweak some config parameters to see if using more worker= s
>> would give me an answer faster, I don't seem to see any obviou= s knobs
>> to turn. Are there parameters that I can adjust to see if I can in= crease
>> throughput? Would adjusting parallel_setup_cost or parallel_tuple_= cost
>> likely to be of help?

See the bit about

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Select the number of work= ers based on the log of the size of
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* the relation.=C2=A0 This = probably needs to be a good deal more
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* sophisticated, but we nee= d something here for now.=C2=A0 Note that

in compute_parallel_worker().=C2=A0 You can move things at the margins by changing min_parallel_table_scan_size, but that logarithmic behavior
will constrain the number of workers pretty quickly.=C2=A0 You'd have t= o
change that code to assign a whole bunch of workers to one scan.

(No, I don't know why it's done like that.=C2=A0 There might be rel= ated
discussion in our archives, but finding it could be difficult.)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--000000000000cdbced0639fad2f1--