Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8973d8

Browse filesBrowse files
committed
doc: expand description of how non-SELECT queries are processed
The previous description of how the executor processes non-SELECT queries was very dense, causing lack of clarity. This expanded text spells it out more simply. Reported-by: fotis.koutoupas@gmail.com Discussion: https://postgr.es/m/160912275508.676.17469511338925622905@wrigleys.postgresql.org Backpatch-through: 9.5
1 parent 085a1cf commit e8973d8
Copy full SHA for e8973d8

File tree

Expand file treeCollapse file tree

1 file changed

+30
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+30
-20
lines changed

‎doc/src/sgml/arch-dev.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/arch-dev.sgml
+30-20Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -528,26 +528,36 @@
528528
</para>
529529

530530
<para>
531-
The executor mechanism is used to evaluate all four basic SQL query types:
532-
<command>SELECT</>, <command>INSERT</>, <command>UPDATE</>, and
533-
<command>DELETE</>. For <command>SELECT</>, the top-level executor
534-
code only needs to send each row returned by the query plan tree off
535-
to the client. For <command>INSERT</>, each returned row is inserted
536-
into the target table specified for the <command>INSERT</>. This is
537-
done in a special top-level plan node called <literal>ModifyTable</>.
538-
(A simple
539-
<command>INSERT ... VALUES</> command creates a trivial plan tree
540-
consisting of a single <literal>Result</> node, which computes just one
541-
result row, and <literal>ModifyTable</> above it to perform the insertion.
542-
But <command>INSERT ... SELECT</> can demand the full power
543-
of the executor mechanism.) For <command>UPDATE</>, the planner arranges
544-
that each computed row includes all the updated column values, plus
545-
the <firstterm>TID</> (tuple ID, or row ID) of the original target row;
546-
this data is fed into a <literal>ModifyTable</> node, which uses the
547-
information to create a new updated row and mark the old row deleted.
548-
For <command>DELETE</>, the only column that is actually returned by the
549-
plan is the TID, and the <literal>ModifyTable</> node simply uses the TID
550-
to visit each target row and mark it deleted.
531+
The executor mechanism is used to evaluate all four basic SQL query
532+
types: <command>SELECT</command>, <command>INSERT</command>,
533+
<command>UPDATE</command>, and <command>DELETE</command>.
534+
For <command>SELECT</command>, the top-level executor code
535+
only needs to send each row returned by the query plan tree
536+
off to the client. <command>INSERT ... SELECT</command>,
537+
<command>UPDATE</command>, and <command>DELETE</command>
538+
are effectively <command>SELECT</command>s under a special
539+
top-level plan node called <literal>ModifyTable</literal>.
540+
</para>
541+
542+
<para>
543+
<command>INSERT ... SELECT</command> feeds the rows up
544+
to <literal>ModifyTable</literal> for insertion. For
545+
<command>UPDATE</command>, the planner arranges that each
546+
computed row includes all the updated column values, plus the
547+
<firstterm>TID</firstterm> (tuple ID, or row ID) of the original
548+
target row; this data is fed up to the <literal>ModifyTable</literal>
549+
node, which uses the information to create a new updated row and
550+
mark the old row deleted. For <command>DELETE</command>, the only
551+
column that is actually returned by the plan is the TID, and the
552+
<literal>ModifyTable</literal> node simply uses the TID to visit each
553+
target row and mark it deleted.
554+
</para>
555+
556+
<para>
557+
A simple <command>INSERT ... VALUES</command> command creates a
558+
trivial plan tree consisting of a single <literal>Result</literal>
559+
node, which computes just one result row, feeding that up
560+
to<literal>ModifyTable</literal> to perform the insertion.
551561
</para>
552562

553563
</sect1>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.