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 1nk5tS-0007g8-4c for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 15:17:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nk5tQ-0002EG-Oo for pgsql-general@arkaria.postgresql.org; Thu, 28 Apr 2022 15:17:20 +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 1nk5tP-0002Dl-SQ for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 15:17:20 +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 1nk5tN-0006gS-O8 for pgsql-general@lists.postgresql.org; Thu, 28 Apr 2022 15:17:18 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 304AB3200974; Thu, 28 Apr 2022 11:17:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 28 Apr 2022 11:17:16 -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=1651159035; x=1651245435; bh=J6VvHCs6qCi2iip1sCQ1ohdM9JwN Q6MkwDGPxCmYpFI=; b=MyXwdoqUcK9Kpj3fxqTdvafn+EQTTOTLS+98meZhggLd cy18RbgxHk/RrOGPP4wwPqbGl6S3dgFYOEUG8OSv6VMA/zQQUwrniZ1h1vk4yP93 ZRLfKFLHY+mOWsaas2WfR4BIFlPIt9EekSh+yjVwSI5Vcca1I10WZYOr+kh8RRij lgBpcyNtbCwANX/XLCMfc7/0eVD0cWtmQjgH7OkbE7YgjdhW+TcLjDtfYKmSOOxV 2Xoqklpa1tfYzFQGvoAok8pyQzEuVxZ3hkIq4E4J4zuB0jeGbFaSOt5QVbHe8U4Q SATO84YhJ+gRAhEdyVqTd7FL975xTV6UVtLHON/I0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudejgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedtgfevueeggefhkedvieduhefgveehjeeijeevveeuiedv ffdufeethedvtddtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 28 Apr 2022 11:17:15 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 2E3F22A1E9D; Thu, 28 Apr 2022 17:17:13 +0200 (CEST) Date: Thu, 28 Apr 2022 17:17:13 +0200 From: Alvaro Herrera To: Shaozhong SHI Cc: pgsql-general Subject: Re: parallel-processing multiple similar query tasks - any example? Message-ID: <202204281517.nznd535364hn@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: > multiple similar query tasks are as follows: > > select * from a_table where country ='UK' > select * from a_table where country='France' > and so on > > How best to parallel-processing such types of multiple similar query tasks? > > Any example available? for country in UK France Germany Ireland; do echo "select pg_sleep(1); select * from a_table where country = '${country//\'/''/}'" done | \ xargs -d"\n" -P10 -n1 psql -X -c Note the ${country/} stuff is a bash-ism. -- Álvaro Herrera