Skip to content

Commit

Permalink
Add documentation for query plan and plan fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
steveburnett committed Oct 14, 2024
1 parent 8ce4ccd commit f40b9da
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
27 changes: 27 additions & 0 deletions presto-docs/src/main/sphinx/overview/concepts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,33 @@ that statement. A query encompasses stages, tasks, splits, connectors,
and other components and data sources working in concert to produce a
result.

Query Plan
^^^^^^^^^^

A query plan is an `operator <https://prestodb.io/docs/current/overview/concepts.html#operator>`_
- a sequence of steps used to access and manipulate data according to the SQL
query. It is represented as a tree of nodes, with each node representing a
logical unit of relational algebra that can be executed by the. engine.
Because query plans can have different performance behavior, Presto uses
a query optimizer to make query plans more efficient.

There are two phases of optimization: logical and physical. The logical
phase of optimization transforms plans by only considering algorithmic
complexity. The logically optimized query plan is then converted into
a physical query plan, which is optimized for distributed execution and
includes details such as the number and
`types <https://prestodb.io/docs/current/overview/concepts.html#server-types>`_
of Presto servers which should process a query plan node, and how data is
`exchanged <https://prestodb.io/docs/current/overview/concepts.html#exchange>`_
between them.

Plan Fragment
^^^^^^^^^^^^^

A plan fragment is a section of the physical query plan executed by
`tasks <https://prestodb.io/docs/current/overview/concepts.html#task>`_ on different
`Presto servers <https://prestodb.io/docs/current/overview/concepts.html#server-types>`_.

Stage
^^^^^

Expand Down
8 changes: 4 additions & 4 deletions presto-docs/src/main/sphinx/sql/explain.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Description
-----------

Show the logical or distributed execution plan of a statement, or validate the statement.
Use ``TYPE DISTRIBUTED`` option to display fragmented plan. Each plan fragment is executed by
a single or multiple Presto nodes. Fragments separation represent the data exchange between Presto nodes.
Fragment type specifies how the fragment is executed by Presto nodes and how the data is
distributed between fragments:
Use ``TYPE DISTRIBUTED`` option to display fragmented plan. Each
`plan fragment <https://prestodb.io/docs/current/overview/concepts.html#plan-fragment>`_
is executed by a single or multiple Presto nodes. Fragment type specifies how the fragment
is executed by Presto nodes and how the data is distributed between fragments:

``SINGLE``
Fragment is executed on a single node.
Expand Down

0 comments on commit f40b9da

Please sign in to comment.