Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 14a608a

Browse 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 49c928c commit 14a608a

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

doc/src/sgml/arch-dev.sgml

+30-20
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>, <command>INSERT</command>, <command>UPDATE</command>, and
533-
<command>DELETE</command>. For <command>SELECT</command>, 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</command>, each returned row is inserted
536-
into the target table specified for the <command>INSERT</command>. This is
537-
done in a special top-level plan node called <literal>ModifyTable</literal>.
538-
(A simple
539-
<command>INSERT ... VALUES</command> command creates a trivial plan tree
540-
consisting of a single <literal>Result</literal> node, which computes just one
541-
result row, and <literal>ModifyTable</literal> above it to perform the insertion.
542-
But <command>INSERT ... SELECT</command> can demand the full power
543-
of the executor mechanism.) For <command>UPDATE</command>, the planner arranges
544-
that each computed row includes all the updated column values, plus
545-
the <firstterm>TID</firstterm> (tuple ID, or row ID) of the original target row;
546-
this data is fed into a <literal>ModifyTable</literal> node, which uses the
547-
information to create a new updated row and mark the old row deleted.
548-
For <command>DELETE</command>, the only column that is actually returned by the
549-
plan is the TID, and the <literal>ModifyTable</literal> 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)