Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk6iY-0002sq-He for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 16:10:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nk6iX-0007KK-FG for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 16:10:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk6iW-0007JU-HJ for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 16:10:09 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk6iT-00075E-SW for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 16:10:07 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D56553200982; Thu, 28 Apr 2022 12:10:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 28 Apr 2022 12:10:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1651162203; x=1651248603; bh=vsyna7u5pov/HchhIrAflOKtPgC7 3Do09gIJlWABfts=; b=mBqNH3/6skQZkwAhvmzggd6G/pYw9qHOG0tL4bSIO7lH NjAbDcbnKfY27OlmriEhpFbaocxoaTEqhZ0N3XMzXnXaB34pN3eb7RIM/bYrB1UT sBas5Q6U7rZAD/68PsmSMj/ElcOFmEhx5evsf6nYMsoj7l6Dobp95JE+a+T5s7Br ah6+3nfg4iXaGhkBlsA0ojV0pqj8JXsmhoVFuV8jx7+eO/lccd9I/yTU1I8aGPdx NQOfLharycobU+sz4bKNzBGIEtNREX1YPDJUnaxYLy1q9nzTJJj3lj4gPnyBvq3I lQwIiWLqCL48c3mErZ9N5stbX+pRhiFTuuu8yu9VYQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudejgdelkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedtgfevueeggefhkedvieduhefgveehjeeijeevveeuiedv ffdufeethedvtddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Apr 2022 12:10:03 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C83D82A1E9D; Thu, 28 Apr 2022 18:10:00 +0200 (CEST) Date: Thu, 28 Apr 2022 18:10:00 +0200 From: Alvaro Herrera To: Shaozhong SHI Cc: pgsql-general Subject: Re: parallel-processing multiple similar query tasks - any example? Message-ID: <202204281610.turgxp6amrah@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Apr-28, Shaozhong SHI wrote: > Why sleep(1)? It is sleeping to show that they are running concurrently. If it runs five sleeps of one second each and the whole command lasts one second, then all sleeps ran in parallel. Had the whole command taken five seconds, you would know that the queries ran serially. > It should be all active - doing work concurrently. They are all active simultaneously. You just need to supply your own query, without any sleeps. -- Álvaro Herrera