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 1nk7jS-0007P6-D7 for pgsql-sql@arkaria.postgresql.org; Thu, 28 Apr 2022 17:15: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 1nk7jR-0003Gm-16 for pgsql-sql@arkaria.postgresql.org; Thu, 28 Apr 2022 17:15: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 1nk7jQ-0003Gd-Ms for pgsql-sql@lists.postgresql.org; Thu, 28 Apr 2022 17:15:08 +0000 Received: from premium22-1.web-hosting.com ([68.65.122.103]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nk7jO-0007dN-8E for pgsql-sql@lists.postgresql.org; Thu, 28 Apr 2022 17:15:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=misuse.org; s=default; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vJnCqzkJHKfhNKeHe1P9+oVAgjCy2BpEr/EWNYK6GhU=; b=ugNjrRiL9hqsnmXa1E5y3VYh/5 J+8sTPvXSVrlSkUZxiZgEbzuI65/Kn3IHen7GGjhQgEQaH19Wz2+L8WiP8ZSOzcIBPPEMsnFPK+65 rjIZXvoMJAauk5W8fbBvyucDRW58QIOHm9bsSsTtzCAdS4DzUkOSwykoo5T7VdAraRKSbvMTeZehR w3t+gY3z0MmehD0YLNkNvLDTuBbYxiAon2zeH0uwFipFwM3JqUOCx0g02rQc+04BZ5Bmrt2FCr6yt l5wIy+PPbYegJhKn+sU+S2bOB08KPDW4w/aC9Z79ZjOrzXKr6eTnT2ikXdvG1F5rkHljHHETzW7EM 8Z03aizA==; Received: from mail-lf1-f53.google.com ([209.85.167.53]:36852) by premium22.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nk7jI-00FzUB-Ca for pgsql-sql@lists.postgresql.org; Thu, 28 Apr 2022 13:15:04 -0400 Received: by mail-lf1-f53.google.com with SMTP id bq30so9823746lfb.3 for ; Thu, 28 Apr 2022 10:14:59 -0700 (PDT) X-Gm-Message-State: AOAM532ds8VcQCuD+EUxJSYh+pmAmtNc9674iFBRxaPYmwwSzItRhSp4 in3zyxcTIJ43WbK3Wq0ijkf/yJkZhdTiIjbXi84= X-Google-Smtp-Source: ABdhPJwAGKrsZfw7Epz/jk0LNGmdZlerBHrHGhxMDz9QzCH98vDB8sTL19gbqgi3+Vw8XfhZfvwmRLGImxMvGFXaj5E= X-Received: by 2002:ac2:4c54:0:b0:472:2323:f4e0 with SMTP id o20-20020ac24c54000000b004722323f4e0mr8987585lfk.295.1651166098715; Thu, 28 Apr 2022 10:14:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Steve Midgley Date: Thu, 28 Apr 2022 10:14:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: parallel-processing multiple similar query tasks - any example? To: Shaozhong SHI Cc: pgsql-sql Content-Type: multipart/alternative; boundary="000000000000c778f505ddba10b0" X-OutGoing-Spam-Status: No, score=4.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - premium22.web-hosting.com X-AntiAbuse: Original Domain - lists.postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - misuse.org X-Get-Message-Sender-Via: premium22.web-hosting.com: authenticated_id: science@misuse.org X-Authenticated-Sender: premium22.web-hosting.com: science@misuse.org X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c778f505ddba10b0 Content-Type: text/plain; charset="UTF-8" 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 --000000000000c778f505ddba10b0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Apr 27, 2022 at 4:34 PM Shaoz= hong SHI <shishaozhong@gmail.c= om> wrote:



multiple similar query tasks ar= e as follows:

select * from a_table where country =3D= 9;UK'
select * from a_table where country=3D'France'<= /div>
and so on

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


=
This depends on how you are engag= ing with the queries when they return results. Let's assume you are run= ning them from a programming environment with an ORM layer. In that case yo= u can run each query in a separate thread and connection pipe, and the quer= ies 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 qu= eries, so your challenge is really figuring out how you will use the result= s of each query and setting up the environment sending the queries to perfo= rm asynchronously.

Steve
--000000000000c778f505ddba10b0--