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 1mXXZc-0002Qr-5Q for pgsql-docs@arkaria.postgresql.org; Mon, 04 Oct 2021 23:40:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mXXZa-0002se-Nu for pgsql-docs@arkaria.postgresql.org; Mon, 04 Oct 2021 23:40:42 +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 1mXXZa-0002sV-Hp for pgsql-docs@lists.postgresql.org; Mon, 04 Oct 2021 23:40:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXXZY-0004UK-Ab for pgsql-docs@lists.postgresql.org; Mon, 04 Oct 2021 23:40:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 194Necac4017320; Mon, 4 Oct 2021 19:40:38 -0400 From: Tom Lane To: cpainterwakefield@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: clarification on chaining of set operations In-reply-to: <163338891727.12510.3939775743980651160@wrigleys.postgresql.org> References: <163338891727.12510.3939775743980651160@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Mon, 04 Oct 2021 23:08:37 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4017318.1633390838.1@sss.pgh.pa.us> Date: Mon, 04 Oct 2021 19:40:38 -0400 Message-ID: <4017319.1633390838@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > Regarding section 7.4 of the documentation. I was curious about the > behavior when combining different set operations in one query, e.g, > query1 op1 query2 op2 query3; > where op1 and op2 are one of UNION, INTERSECT, EXCEPT. > The documentation suggests that this is equivalent to > (query1 op1 query2) op2 query3; > but only states it for the case when op1 = op2 = UNION. The SELECT reference page explains that INTERSECT binds more tightly than UNION or EXCEPT. I think it's an oversight that section 7.4 doesn't mention that. regards, tom lane