Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBHbT-0005av-6O for pgsql-performance@arkaria.postgresql.org; Tue, 02 Apr 2019 11:29:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hBHbQ-0001VY-PN for pgsql-performance@arkaria.postgresql.org; Tue, 02 Apr 2019 11:29:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBHbQ-0001VR-DE for pgsql-performance@lists.postgresql.org; Tue, 02 Apr 2019 11:29:16 +0000 Received: from mx2a.mailbox.org ([2001:67c:2050:104:0:2:25:2] helo=mx2.mailbox.org) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBHbI-00007d-Uh for pgsql-performance@lists.postgresql.org; Tue, 02 Apr 2019 11:29:15 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 30345A123C; Tue, 2 Apr 2019 13:29:00 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id N5-7qhcOe7YA; Tue, 2 Apr 2019 13:28:52 +0200 (CEST) Message-ID: <9f0f08fd2cc134e6f320a8936e86383450449f54.camel@cybertec.at> Subject: Re: parallel query From: Laurenz Albe To: Mariel Cherkassky , pgsql-performance@lists.postgresql.org Date: Tue, 02 Apr 2019 13:28:50 +0200 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mariel Cherkassky wrote: > I wanted to a few questions regarding the parallel parameters : max_worker_processes and max_parallel_workers_per_gather. > > 1)Basically, max_worker_processes should be set to the number of cpus I have in the machine ? Setting it higher would not be smart. Setting it lower can also be a good idea; it depends on your workload. > 2)If I set max_worker_processes to X and max_parallel_workers_per_gather to Y (X>Y) > it means that I will have at max (X/2) queries that can run in parallel. Am I right ? > For example, max_worker_processes =8,max_parallel_workers_per_gather =4, it means > that at max I can have 4 queries that are running in parallel ? and at min 2 queries > (or none) can run in parallel ? That is correct, but unless you set "max_parallel_workers_per_gather" to 1, one query can use more than one parallel worker, and then you can have fewer concurrent queries. It also depends on the size of the table or index how many workers PostgreSQL will use. > 3)So If I calculate my work_mem based on the number of sessions I have : (TOTAL_MEM/2/NUM_OF_CONNECTIONS) > I should add 8 to the NUM_OF_CONNECTIONS to have a new value for the work_mem in order to consider queries that run in parallel.. Yes, but don't forget that one query can use "work_mem" several times if the execution plan has several memory intensive nodes. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com