UltipaDocs
Try Playground
  • Introduction
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Typed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Managing HDC Graphs
    • HDC Graph Queries
  • Transaction
  • Trigger
    • Process
    • Job
    • Execution Plan
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • Access Control
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. GQL Execution

Execution Plan

Overview

When a GQL query is submitted to Ultipa, it first undergoes parsing to validate its syntax. Once parsed, the query is passed through an optimization phase where Ultipa evaluates potential execution strategies based on the current state of the database.

Ultipa’s query optimizer selects the most efficient execution plan by considering factors like data distribution, indexing, and potential bottlenecks. This execution plan outlines the optimal sequence of operations, minimizing resource consumption and improving query performance.


Lifecycle of a GQL query

To examine the execution plan of a query, prefix it with either EXPLAIN or PROFILE.

EXPLAIN

The EXPLAIN generates the execution plan for a query without actually running it. It provides a detailed tree of execution operators that outlines the steps the query engine will take to retrieve the desired results.

GQL
EXPLAIN
MATCH (n:account)
RETURN n.name
LIMIT 10

The output is a structured representation of the execution plan, often referred to as _explain.

_explain
Return{expr:[n.name]  row_type:n.name:STRING}
->    With{exprs:[n_2  as  n],row_type:n:  NODE}
        ->    Limit{limit:10,phase:DEFAULT,row_type:n_2:  NODE}
                ->    NodeSearch{alias:n_2,access_method:{condition:@account,index_name:schema,query_type:SK_SCHEMA_SCAN},row_type:n_2:  NODE}

PROFILE

PROFILE runs the query and returns both the query results and a profile_info table. This table includes details such as the execution operators used, the number of rows each operator produces, and the time cost of each step.

GQL
PROFILE
MATCH (n:account)
RETURN n.name
LIMIT 10

Sample profile_info output:

levelop_nameop_idtime_costrows
--1RETURN117μs121
----2WITH28μs121
------3LIMIT_SKIP31μs121
--------4NODE_SCAN4440μs121