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 1jQurl-00071c-6O for pgsql-docs@arkaria.postgresql.org; Tue, 21 Apr 2020 15:31:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQurj-00064I-NG for pgsql-docs@arkaria.postgresql.org; Tue, 21 Apr 2020 15:31:15 +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 1jQurj-00064B-HM for pgsql-docs@lists.postgresql.org; Tue, 21 Apr 2020 15:31:15 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQurg-0003NM-LU for pgsql-docs@postgresql.org; Tue, 21 Apr 2020 15:31:15 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1jQurd-0003m3-IW; Tue, 21 Apr 2020 11:31:09 -0400 Date: Tue, 21 Apr 2020 11:31:09 -0400 From: Bruce Momjian To: Alvaro Herrera Cc: Marc =?iso-8859-1?Q?Recht=E9?= , pgsql-docs@postgresql.org Subject: Re: Backend Flowchart / Developer doc Message-ID: <20200421153109.GD19613@momjian.us> References: <20200416151729.GA9284@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200416151729.GA9284@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Thu, Apr 16, 2020 at 11:17:29AM -0400, Alvaro Herrera wrote: > On 2020-Apr-15, Marc Rechté wrote: > > > Hello, > > > > Don't know if this the correct list to submit this issue. > > > > On the https://www.postgresql.org/developer/backend/, it mentions a > > Query.qual field which does not exist in the Query structure. > > I think that diagram (and the accompanying wiki page) requires a *lot* > of more significant updating than just that field. It is wildly > outdated. I developed the attached patch to fix the items I saw needed updating. -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription + --Q68bSM7Ycu6FN28Q Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="backend.diff" diff --git a/templates/pages/developer/backend.html b/templates/pages/developer/backend.html index ab7e5d6..7337a07 100644 --- a/templates/pages/developer/backend.html +++ b/templates/pages/developer/backend.html @@ -56,7 +56,7 @@ or SelectStmt.

The statement is then identified as complex (SELECT / INSERT / -UPDATE / DELETE) or simple, e.g CREATE USER, ANALYZE, +UPDATE / DELETE) or simple, e.g CREATE ROLE, ANALYZE, etc. Simple utility commands that do not require the executor are processed by statement-specific functions in the commands module. Complex statements require more handling.

@@ -64,11 +64,12 @@ Complex statements require more handling.

The parser takes a complex query, and creates a Query structure that contains all the elements used by complex queries. -Query.qual holds the WHERE clause qualification, which is filled +Query.jointree holds the FROM and WHERE clauses, which is filled in by transformFromClause() and href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/parse_clause.c">transformWhereClause(). Each table referenced in the query is represented by a RangeTableEntry, +href="https://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h">RangeTblEntry, and they are linked together to form the range table of the query, which is generated by transformFromClause(). @@ -95,8 +96,8 @@ system.

The optimizer uses the Query structure to determine the best table join order and join -type of each table in the RangeTable, using Query.qual(WHERE -clause) to consider optimal index usage.

The FROM +and WHERE clauses) to consider optimal index usage.

The
path module then generates an optimal Plan, --Q68bSM7Ycu6FN28Q--