Skip to content

EXPLAIN and PROFILE

EXPLAIN helps output the execution plan of an nGQL statement without executing the statement. PROFILE executes the statement, then outputs the execution plan as well as the execution profile. You can optimize the queries for better performance with the execution plan and profile.

Execution Plan

The execution plan is determined by the execution planner in the Nebula Graph query engine.

The execution planner processes the parsed nGQL statements into actions. An action is the smallest unit that can be executed. A typical action fetches all neighbors of a given vertex, gets the properties of an edge, or filters vertices or edges based on the given conditions. Each action is assigned to an operator that performs the action.

For example, a SHOW TAGS statement is processed into two actions and assigned to a Start operator and a ShowTags operator, while a more complex GO statement may be processed into more than 10 actions and assigned to 10 operators.

Syntax

  • EXPLAIN
EXPLAIN [format="row" | "dot"] <your_nGQL_statement>
  • PROFILE
PROFILE [format="row" | "dot"] <your_nGQL_statement>

Output formats

The output of an EXPLAIN or a PROFILE statement has two formats, the default "row" format and the "dot" format. You can use the format option to modify the output format. Omitting the format option indicates using the default "row" format.

Format "row"

The "row" format outputs the return message in a table as follows.

  • EXPLAIN:

    nebula> EXPLAIN format="row" SHOW TAGS;
    Execution succeeded (time spent 104/705 us)
    Execution Plan
    +----+----------+--------------+----------------+-----------------------------------------------------------------------+
    | id | name     | dependencies | profiling data | operator info                                                         |
    +----+----------+--------------+----------------+-----------------------------------------------------------------------+
    |  0 | ShowTags | 2            |                | outputVar: [  {"colNames":[],"name":"__ShowTags_0","type":"DATASET"}] |
    |    |          |              |                | inputVar:                                                             |
    +----+----------+--------------+----------------+-----------------------------------------------------------------------+
    |  2 | Start    |              |                | outputVar: [  {"colNames":[],"name":"__Start_2","type":"DATASET"}]    |
    +----+----------+--------------+----------------+-----------------------------------------------------------------------+
    
  • PROFILE:

    nebula> PROFILE format="row" SHOW TAGS;
    +--------+
    | Name   |
    +--------+
    | player |
    +--------+
    | team   |
    +--------+
    Got 2 rows (time spent 2038/2728 us)
    
    Execution Plan
    
    +----+----------+--------------+----------------------------------------------------+---------------------------------------------------------------------+
    | id | name     | dependencies | profiling data                                     | operator info                                                       |
    +----+----------+--------------+----------------------------------------------------+---------------------------------------------------------------------+
    |  0 | ShowTags | 2            | ver: 0, rows: 1, execTime: 79us, totalTime: 1692us | outputVar: [{"colNames":[],"name":"__ShowTags_0","type":"DATASET"}] |
    |    |          |              |                                                    | inputVar:                                                           |
    +----+----------+--------------+----------------------------------------------------+---------------------------------------------------------------------+
    |  2 | Start    |              | ver: 0, rows: 0, execTime: 1us, totalTime: 57us    | outputVar: [{"colNames":[],"name":"__Start_2","type":"DATASET"}]    |
    +----+----------+--------------+----------------------------------------------------+---------------------------------------------------------------------+
    

The descriptions of the columns are as follows:

Column Description
id Indicates the ID of the operator.
name Indicates the name of the operator.
dependencies Shows the ID of the operator that the current operator depends on.
profiling data Shows the execution profile. ver is the version of the operator, which you can use to identify loops; rows shows the number of rows to be output by the operator; execTime shows the execution time only; totalTime contains the execution time and the system scheduling and queueing time.
operator info Shows the detailed information of the operator.

Format "dot"

You can use the format="dot" option to output the return message in the DOT language, and then use Graphviz to generate a graph of the plan.

Note

Graphviz is open source graph visualization software.

Graphviz provides an online tool for previewing DOT language files and exporting them to other formats such as SVG or JSON. For more information, see Graphviz Online.

nebula> EXPLAIN format="dot" SHOW TAGS;
Execution succeeded (time spent 161/665 us)
Execution Plan
---------------------------------------------------------------------------------------------------------------------------------------------  -------------
  plan
---------------------------------------------------------------------------------------------------------------------------------------------  -------------
  digraph exec_plan {
      rankdir=LR;
      "ShowTags_0"[label="ShowTags_0|outputVar: \[\{\"colNames\":\[\],\"name\":\"__ShowTags_0\",\"type\":\"DATASET\"\}\]\l|inputVar:\l",   shape=Mrecord];
      "Start_2"->"ShowTags_0";
      "Start_2"[label="Start_2|outputVar: \[\{\"colNames\":\[\],\"name\":\"__Start_2\",\"type\":\"DATASET\"\}\]\l|inputVar: \l",   shape=Mrecord];
  }
---------------------------------------------------------------------------------------------------------------------------------------------  -------------

Transformed into a Graphviz graph, it is as follows:

Graphviz graph of EXPLAIN SHOW TAGS


Last update: April 22, 2021
Back to top