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 1nk8Dd-0001kn-KY for pgsql-sql@arkaria.postgresql.org; Thu, 28 Apr 2022 17:46:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nk8Db-0006Oz-OS for pgsql-sql@arkaria.postgresql.org; Thu, 28 Apr 2022 17:46:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk8Db-0006Oq-E5 for pgsql-sql@lists.postgresql.org; Thu, 28 Apr 2022 17:46:19 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nk8DV-0003iS-4f for pgsql-sql@lists.postgresql.org; Thu, 28 Apr 2022 17:46:19 +0000 Received: by mail-ej1-x631.google.com with SMTP id i19so10989745eja.11 for ; Thu, 28 Apr 2022 10:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CEf7XiBBs549kg+mEeHqvfQIImhCavJkqFZDUVuBh5k=; b=HK5eGJ/F1YPA/p9BIeVGfk+aWGip11inuYEupJ+7bWl/CamGyhMY0HQTTOyN3fxBEL KVfeWIC3S28VO2rxgfKuLe/gCcIWbbdSyRRihmY7qgccDniPpEY62Va60xiK6c6KNjYp 2JwmpKtrC41/z5IFWWZGmX/XAPvZPZlih5yTvd8iklclob8z10NWOfFlK18KjguSuBr0 LMPOtngpFNEO9P7yX7fCtljHLD4ns8J6q/6UUvcuqxa04xRlORiuu/9h+5EqU6fXJzIp ykP5U8+a5jN2BwG5CatxfpNeW3pJBc8wUqKJyeCcXony2ya2FqfCU3SjlfaOGQvjL1XE +zOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CEf7XiBBs549kg+mEeHqvfQIImhCavJkqFZDUVuBh5k=; b=whIsU3KYOYp+REgfzbyqrgdixDRiBfzsBoSQ1IVQugyepPCjJFiB8GmNOtCVQLJVUJ MTnFH8Zoih3biWkjPHitubsHYNKcM6mxjjZJyp9pVVH08oRfo/7+/Up9fZ2NAQYgYG9V 8NdQltJZ/u+3XB8K81VrfFoqbXYdWKR16IsJWp6Rew/vERpCOYT1Gk7PvlNO/4I+iFfS hM23DqhGwlZW0jQzzYhTx4bwLnysBgj9BOYzWivECXRA81Q0dg59rwGXdX6gcHSkF0mA gPMBoEw4TAbvOqDKYD5CJ6cShCeAuAfT6mXcyz0LCHRWdKjduLWuytxzr155wOWTJOcs F9Lg== X-Gm-Message-State: AOAM533pHCdXRhTAWxPzPt3gXtZX60asSpKqZ4z9VJ2M6SACTmgSKgzx Y40wlQEWd8IuwFX/mUbyMmFRG66niOcienz7yuk= X-Google-Smtp-Source: ABdhPJzrnZliZH5zR+AmKQ/We2bZBZNwYSq3+m6mxv1xZTCPBwNFLn9V+huAoaPOblkvK/0lRaDM7DY9tHljyDpOCZc= X-Received: by 2002:a17:907:8b13:b0:6f3:9216:b73e with SMTP id sz19-20020a1709078b1300b006f39216b73emr22954642ejc.188.1651167972142; Thu, 28 Apr 2022 10:46:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shaozhong SHI Date: Thu, 28 Apr 2022 18:46:01 +0100 Message-ID: Subject: Re: parallel-processing multiple similar query tasks - any example? To: Steve Midgley Cc: pgsql-sql Content-Type: multipart/alternative; boundary="00000000000071b6e605ddba80a9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000071b6e605ddba80a9 Content-Type: text/plain; charset="UTF-8" On Thu, 28 Apr 2022 at 18:15, Steve Midgley wrote: > > > On Wed, Apr 27, 2022 at 4:34 PM 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? >> >> >> This depends on how you are engaging with the queries when they return > results. Let's assume you are running them from a programming environment > with an ORM layer. In that case you can run each query in a separate thread > and connection pipe, and the queries will run async just fine. If you are > running at the command line using psql, you can just open multiple shells > and run each query from a different shell terminal. > > Postgres is very good at async queries, so your challenge is really > figuring out how you will use the results of each query and setting up the > environment sending the queries to perform asynchronously. > > Steve > Hi, Steve, That is very useful. All we want to do is to process a large amount of data. I found loops of recursive queries are very time consuming and will not finish on time. Measures like indexing are simply not adequate to address the problem. I am thinking of making use of Linux capability to fire off concurrent processors. So long as it is efficient, we can always work out how to ask it to return results. Regards, David --00000000000071b6e605ddba80a9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, 28 Apr 2022 at 18:15, Steve M= idgley <science@misuse.org>= wrote:


On Wed, Apr 27, 2022 at 4:34 PM Shaozhong SHI= <shishaozho= ng@gmail.com> wrote:



multiple similar quer= y tasks are as follows:

select * from a_table where coun= try =3D'UK'
select * from a_table where country=3D'Fr= ance'
and so on

How best to parallel= -processing such types of multiple similar query tasks?


This depends on how you= are engaging with the queries when they return results. Let's assume y= ou are running them from a programming environment with an ORM layer. In th= at case you can run each query in a separate thread and connection pipe, an= d the queries will run async just fine. If you are running at the command l= ine using psql, you can just open multiple shells and run each query from a= different shell terminal.

Postgres is very good a= t async queries, so your challenge is really figuring out how you will use = the results of each query and setting up the environment sending the querie= s to perform asynchronously.

Steve

Hi, Steve,

That= is very useful.

All we want to do is to process a= large amount of data.

I found loops of recursive = queries are very time consuming and will not finish on time.

=
Measures like indexing are simply not adequate to address the pr= oblem.

I am thinking of making use of Linux capabi= lity to fire off concurrent processors.

So long as= it is efficient, we can always work out how to ask it to return results.

Regards,

David=C2=A0
=
--00000000000071b6e605ddba80a9--