Permalink
Browse files

Add back the backend flowchart to the website

Bruce Momjian, with surprisingly few modifications by me
  • Loading branch information...
1 parent fff7edf commit 93259880c55ab326e518c7d6fd488557a19e7599 @mhagander mhagander committed Sep 4, 2012
@@ -0,0 +1,143 @@
+#FIG 3.2 Produced by xfig version 3.2.5b
+Portrait
+Center
+Inches
+Letter
+88.00
+Single
+-2
+1200 2
+0 32 #919191
+0 33 #c5ddc1
+2 4 0 1 -1 26 1 0 20 0.000 0 0 7 0 0 5
+ 3600 900 1200 900 1200 300 3600 300 3600 900
+2 4 0 1 -1 4 1 0 20 0.000 0 0 7 0 0 5
+ 3600 2100 1200 2100 1200 1500 3600 1500 3600 2100
+2 4 0 1 -1 0 1 0 20 0.000 0 0 7 0 0 5
+ 7500 1500 5100 1500 5100 900 7500 900 7500 1500
+2 4 0 1 -1 31 1 0 20 0.000 0 0 7 0 0 5
+ 3600 3300 1200 3300 1200 2700 3600 2700 3600 3300
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 6000 1200 6000 1200 5400 3600 5400 3600 6000
+2 4 0 1 -1 31 1 0 20 0.000 0 0 7 0 0 5
+ 7500 3300 5100 3300 5100 2700 7500 2700 7500 3300
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 8400 1200 8400 1200 7800 3600 7800 3600 8400
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 9600 1200 9600 1200 9000 3600 9000 3600 9600
+2 1 2 2 -1 7 0 0 -1 3.000 0 1 -1 1 1 2
+ 0 0 2.00 80.00 150.00
+ 0 0 2.00 80.00 150.00
+ 4500 1425 5135 1194
+2 1 2 2 -1 7 0 0 -1 4.000 0 1 -1 1 1 2
+ 0 0 2.00 80.00 150.00
+ 0 0 2.00 80.00 150.00
+ 4725 2025 5160 1467
+2 1 0 2 20 7 1 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 2100 2400 2700
+2 1 0 2 31 7 1 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 3300 2400 4275
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 7200 1200 7200 1200 6600 3600 6600 3600 7200
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 10800 1200 10800 1200 10200 3600 10200 3600 10800
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 8400 2400 9000
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 7200 2400 7800
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 6000 2400 6600
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 4800 2400 5400
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 3600 5700 5100 5700
+2 1 0 2 25 7 0 0 -1 0.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.50
+ 2400 900 2400 1500
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 7500 6000 5100 6000 5100 5400 7500 5400 7500 6000
+2 4 0 1 33 33 3 0 20 0.000 0 0 40 0 0 5
+ 8700 11100 300 11100 300 3600 8700 3600 8700 11100
+2 1 0 2 29 7 0 0 -1 0.000 0 0 -1 1 1 2
+ 0 0 2.00 150.00 180.00
+ 0 0 2.00 150.00 180.00
+ 3150 13050 3150 13650
+2 1 0 2 29 7 0 0 -1 0.000 0 0 -1 1 1 2
+ 0 0 2.00 150.00 180.00
+ 0 0 2.00 150.00 180.00
+ 1500 12450 1500 11850
+2 4 0 1 -1 29 1 0 20 0.000 0 0 7 0 0 5
+ 2700 13050 300 13050 300 12450 2700 12450 2700 13050
+2 4 0 1 -1 29 1 0 20 0.000 0 0 7 0 0 5
+ 6000 13050 3600 13050 3600 12450 6000 12450 6000 13050
+2 4 0 1 -1 29 1 0 20 0.000 0 0 7 0 0 5
+ 7500 14250 5100 14250 5100 13650 7500 13650 7500 14250
+2 4 0 1 -1 29 1 0 20 0.000 0 0 7 0 0 5
+ 4200 14250 1800 14250 1800 13650 4200 13650 4200 14250
+2 1 0 2 29 7 0 0 -1 0.000 0 0 -1 1 1 2
+ 0 0 2.00 150.00 180.00
+ 0 0 2.00 150.00 180.00
+ 4800 12450 4800 11850
+2 1 0 2 29 7 0 0 -1 0.000 0 0 -1 1 1 2
+ 0 0 2.00 150.00 180.00
+ 0 0 2.00 150.00 180.00
+ 6300 13050 6300 13650
+2 4 0 1 -1 29 1 0 20 0.000 0 0 7 0 0 5
+ 9300 13050 6600 13050 6600 12450 9300 12450 9300 13050
+2 1 0 2 29 7 0 0 -1 0.000 0 0 -1 1 1 2
+ 0 0 2.00 150.00 180.00
+ 0 0 2.00 150.00 180.00
+ 7950 11850 7950 12450
+2 1 1 2 5 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 6000 2400 6600
+2 1 1 2 32 7 1 0 -1 4.000 0 0 -1 1 0 2
+ 0 0 2.00 150.00 180.00
+ 2400 9600 2400 10200
+2 4 0 1 -1 8 1 0 20 0.000 0 0 7 0 0 5
+ 3600 4800 1200 4800 1200 4200 3600 4200 3600 4800
+3 2 2 2 20 7 0 0 -1 6.000 1 1 0 5
+ 0 0 2.00 150.00 180.00
+ 2415 2140 3090 2440 5265 2515 6090 2590 6315 2740
+ 0.000 -1.000 -1.000 -1.000 0.000
+3 0 1 2 32 7 1 0 -1 4.500 0 1 0 7
+ 0 0 2.00 150.00 150.00
+ 7500 5700 8400 5400 8400 4500 7800 3900 3600 3900 3000 3900
+ 2700 4200
+ 0.000 1.000 1.000 1.000 1.000 1.000 0.000
+3 0 1 2 32 7 0 0 -1 4.000 0 1 0 8
+ 0 0 2.00 150.00 150.00
+ 1125 10500 900 10350 675 9975 675 4350 900 3975 1350 3900
+ 1800 3900 2100 4200
+ 0.000 1.000 1.000 1.000 1.000 1.000 1.000 0.000
+4 1 5 2 0 28 18 0.0000 4 285 870 4350 5625 utility\001
+4 1 -1 0 0 16 18 0.0000 4 210 1455 2400 1950 Postmaster\001
+4 1 -1 0 0 16 18 0.0000 4 270 1125 2400 3150 Postgres\001
+4 1 -1 0 0 16 18 0.0000 4 270 1125 6300 3150 Postgres\001
+4 1 7 0 0 16 18 0.0000 4 270 720 6300 1350 Libpq\001
+4 1 -1 0 0 16 18 0.0000 4 210 615 2400 750 Main\001
+4 1 7 0 0 16 18 0.0000 4 210 1815 2400 9450 Generate Plan\001
+4 1 7 0 0 16 18 0.0000 4 270 1440 2400 5850 Traffic Cop\001
+4 1 7 0 0 16 18 0.0000 4 210 1980 2400 8250 Generate Paths\001
+4 1 5 2 0 28 18 0.0000 4 225 615 2400 9900 Plan\001
+4 1 5 2 0 28 18 0.0000 4 285 1920 2400 8700 Optimal Path\001
+4 1 5 2 0 28 18 0.0000 4 285 900 2400 6300 Query\001
+4 1 7 0 0 16 18 0.0000 4 210 1680 2400 10650 Execute Plan\001
+4 0 5 0 0 16 12 0.0000 4 210 2640 5250 6300 e.g. CREATE TABLE, COPY\001
+4 1 5 0 0 16 12 0.0000 4 195 3540 2400 6525 SELECT, INSERT, UPDATE, DELETE\001
+4 1 7 0 0 16 18 0.0000 4 270 1800 2400 7050 Rewrite Query\001
+4 1 7 0 0 16 18 0.0000 4 210 2130 2400 4650 Parse Statement\001
+4 1 7 0 0 16 18 0.0000 4 270 720 6300 5700 Utility\001
+4 1 7 0 0 16 18 0.0000 4 210 1335 6300 6000 Command\001
+4 1 -1 0 0 16 18 0.0000 4 270 2355 7950 12900 Storage Managers\001
+4 1 -1 0 0 16 18 0.0000 4 270 1020 4800 12900 Catalog\001
+4 1 -1 0 0 16 18 0.0000 4 210 915 1500 12900 Utilities\001
+4 1 -1 0 0 16 18 0.0000 4 210 2085 3000 14100 Access Methods\001
+4 1 -1 0 0 16 18 0.0000 4 210 1635 6300 14100 Nodes / Lists\001
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,116 @@
+{%extends "base/page.html"%}
+{%block title%}Backend Flowchart{%endblock%}
+{%block contents%}
+
+<h1>Backend Flowchart</h1>
+
+<center>
+<h3><i>Click on an item</i> to see more detail or look at the full
+<a href="http://wiki.postgresql.org/wiki/Backend_flowchart">index.</a></h3>
+
+<p><img src="../../../media/img/developer/backend/flow.gif" usemap="#flowmap" alt="flowchart" />
+
+<!--
+image size 529 820
+clickable area size 145x45; to compute closing corner, use:
+echo "0, 0," | awk -F, '{printf "%d, %d\n", $1 + 145, $2 + 45}'
+ -->
+
+<map name="flowmap" id="flowmap">
+<area coords="50, 0, 195, 45" href="http://wiki.postgresql.org/wiki/Backend_flowchart#main" alt="main" />
+<area coords="50, 65, 195, 110" href="http://wiki.postgresql.org/wiki/Backend_flowchart#postmaster" alt="postmaster" />
+<area coords="50, 135, 195, 180" href="http://wiki.postgresql.org/wiki/Backend_flowchart#tcop" alt="tcop" />
+<area coords="50, 225, 195, 270" href="http://wiki.postgresql.org/wiki/Backend_flowchart#parser" alt="parser" />
+<area coords="50, 295, 195, 340" href="http://wiki.postgresql.org/wiki/Backend_flowchart#tcop" alt="tcop" />
+<area coords="50, 365, 195, 410" href="http://wiki.postgresql.org/wiki/Backend_flowchart#rewrite" alt="rewrite" />
+<area coords="50, 435, 195, 480" href="http://wiki.postgresql.org/wiki/Backend_flowchart#optimizer_path" alt="path" />
+<area coords="50, 505, 195, 550" href="http://wiki.postgresql.org/wiki/Backend_flowchart#optimizer_plan" alt="plan" />
+<area coords="50, 575, 195, 620" href="http://wiki.postgresql.org/wiki/Backend_flowchart#executor" alt="executor" />
+
+<area coords="280, 35, 425, 80" href="http://wiki.postgresql.org/wiki/Backend_flowchart#libpq" alt="libpq" />
+<area coords="280, 135, 425, 180" href="http://wiki.postgresql.org/wiki/Backend_flowchart#tcop" alt="tcop" />
+<area coords="280, 285, 425, 330" href="http://wiki.postgresql.org/wiki/Backend_flowchart#commands" alt="commands" />
+
+<area coords="0, 710, 145, 755" href="http://wiki.postgresql.org/wiki/Backend_flowchart#utils" alt="utils" />
+<area coords="190, 710, 335, 755" href="http://wiki.postgresql.org/wiki/Backend_flowchart#catalog" alt="catalog" />
+<area coords="365, 710, 510, 755" href="http://wiki.postgresql.org/wiki/Backend_flowchart#storage" alt="storage" />
+
+<area coords="85, 780, 230, 825" href="http://wiki.postgresql.org/wiki/Backend_flowchart#access" alt="access" />
+<area coords="280, 780, 425, 825" href="http://wiki.postgresql.org/wiki/Backend_flowchart#nodes" alt="nodes" />
+</map>
+</center>
+
+<br />
+
+<p>A query comes to the backend via data packets arriving through TCP/IP
+or Unix Domain sockets. It is loaded into a string, and passed to the <a
+href="http://wiki.postgresql.org/wiki/Backend_flowchart#parser">parser,</a>
+where the lexical scanner, <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/scan.l">scan.l,</a>
+breaks the query up into tokens(words). The parser uses <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/gram.y">gram.y</a>
+and the tokens to identify the query type, and load the proper
+query-specific structure, like <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h">CreateStmt</a>
+or <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h">SelectStmt.</a></p>
+
+<p>The statement is then identified as complex (<i>SELECT / INSERT /
+UPDATE / DELETE</i>) or a simple, e.g <i> CREATE USER, ANALYZE, </i>,
+etc. Simple utility commands are processed by statement-specific
+functions in <a href="../../backend/commands">backend/commands.</a>
+Complex statements require more handling.</p>
+
+<p>The parser takes a complex query, and creates a <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h">Query</a>
+structure that contains all the elements used by complex queries.
+Query.qual holds the <i>WHERE</i> clause qualification, which is filled
+in by <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/parse_clause.c">transformWhereClause().</a>
+Each table referenced in the query is represented by a <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/parsenodes.h">RangeTableEntry,</a>
+and they are linked together to form the <i>range table</i> of the
+query, which is generated by <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/parse_clause.c">transformFromClause().</a>
+Query.rtable holds the query's range table.</p>
+
+<p>Certain queries, like <i>SELECT,</i> return columns of data. Other
+queries, like <i>INSERT</i> and <i>UPDATE,</i> specify the columns
+modified by the query. These column references are converted to <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/primnodes.h">TargetEntry</a>
+entries, which are linked together to make up the <i>target list</i> of
+the query. The target list is stored in Query.targetList, which is
+generated by <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/parser/parse_target.c">transformTargetList().</a></p>
+
+<p>Other query elements, like aggregates(<i>SUM()</i>), <i>GROUP
+BY,</i> and <i>ORDER BY</i> are also stored in their own Query
+fields.</p>
+
+<p>The next step is for the Query to be modified by any
+<i>VIEWS</i> or <i>RULES</i> that may apply to the query. This is
+performed by the <a href="http://wiki.postgresql.org/wiki/Backend_flowchart#rewrite">rewrite</a>
+system.</p>
+
+<p>The <a
+href="http://wiki.postgresql.org/wiki/Backend_flowchart#optimizer_path">optimizer</a>
+uses the Query structure to determine the best table join order and join
+type of each table in the RangeTable, using Query.qual(<i>WHERE</i>
+clause) to consider optimal index usage.</p> The <a
+href="http://wiki.postgresql.org/wiki/Backend_flowchart#optimizer_path">path</a>
+module then generates an optimal <a
+href="http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/include/nodes/plannodes.h">Plan,</a>
+which contains the operations to be performed to execute the query.
+
+<p>The Plan is then passed to the <a
+href="http://wiki.postgresql.org/wiki/Backend_flowchart#executor">executor</a> for execution, and the
+result returned to the client. The Plan is actually as set of nodes,
+arranged in a tree structure with a top-level node, and various
+sub-nodes as children.</p>
+
+<p>There are many other modules that support this basic
+functionality. They can be accessed by clicking on the
+flowchart.</p>
+
+{%endblock%}
+
@@ -11,6 +11,7 @@
<li><a href="http://git.postgresql.org/gitweb?p=postgresql.git">Web interface to the Source Code Repository</a></li>
<li><a href="/docs/current/static/git.html">Information about the Source Code Repository</a></li>
<li><a href="http://doxygen.postgresql.org/">Source Code Browser</a> (Doxygen)</li>
+ <li><a href="/developer/backend/">Backend Flowchart</a></li>
<li><a href="http://babel.postgresql.org/">Translating</a></li>
<li><a href="http://wiki.postgresql.org/wiki/Developer_and_Contributor_Resources">Developer Section on wiki.postgresql.org</a></li>
<li>

0 comments on commit 9325988

Please sign in to comment.