UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Reserved Words
    • Data Types
    • Alias
    • Operators
    • Expression
    • Filter
    • Prefix
    • Node and Edge Templates
    • Homologous and Heterologous Data
    • Clause Execution Times
    • Graphset
    • Schema
    • Property
    • Insert
    • Overwrite
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • Find Subgraphs
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • BATCH
      • Schema Checker
      • Equal
      • Not Equal
      • Less Than
      • Greater Than
      • Less Than or Equal
      • Greater Than or Equal
      • Between
      • Between or Equal
      • Beong to
      • Not Belong To
      • CONTAINS | String
      • CONTAINS | Full-Text
      • Regular Match
      • IS NULL
      • IS NOT NULL
      • And
      • Or
      • Not
      • Exclusive OR
      • DISTINCT
      • toString()
      • toInteger()
      • toFloat()
      • toDouble()
      • toDecimal()
      • toSet()
      • castToRaw()
      • now()
      • dateAdd()
      • dateDiff()
      • year()
      • month()
      • day()
      • dayOfWeek()
      • dateFormat()
      • point()
      • distance()
      • pointInPolygon()
      • lower()
      • upper()
      • reverse()
      • startsWith()
      • endsWith()
      • JSON_decode()
      • JSON_merge()
      • trim()
      • ltrim()
      • rtrim()
      • left()
      • right()
      • substring()
      • replace()
      • split()
      • intersection()
      • difference()
      • listUnion()
      • size()
      • head()
      • reduce()
      • listContains()
      • append()
      • pi()
      • pow()
      • sqrt()
      • abs()
      • floor()
      • ceil()
      • round()
      • sin()
      • cos()
      • tan()
      • cot()
      • asin()
      • acos()
      • atan()
      • length()
      • pnodes()
      • pedges()
      • count()
      • sum()
      • max()
      • min()
      • avg()
      • stddev()
      • collect()
      • dedup()
      • CASE
      • table()
      • coalesce()
      • ifnull()
    • Acceleration
    • Index
    • Full-text
    • LTE
    • Real-time Process
    • Backend Task
    • Analytics Node
    • Server Statistics
    • Server Backup
    • Privilege
    • Policy
    • User
  • Trigger
  1. Docs
  2. /
  3. UQL
  4. /
  5. Syntax

Clause Execution Times

Overview

When a chained clause calls an alias or multiple homologous aliases, the number of times that clause executes equals the number of entries contained in the data represented by the alias. Each execution processes one data entry, while system optimizations may apply based on the actual situation. For the query clauses, each execution of the query is also referred to as a subquery.

However, when a chained clause calls heterologous aliases, the number of times that clause executes depends on the alias with the fewest data entries.

General

Example: n has 4 rows, the deletion clause is executed 4 times, each time deleting 1 node.

Example: These two UQLs yield the same results but differ in their executions:

  • In part (a) where the find().nodes() clause takes colors in its filter, which contains two data entries, the clause executes 2 times.
  • In part (b) where the find().nodes() takes no alias in its filter, it executes only once.

CALL Clause

The CALL clause can be used to perform processing for each row of the data independently.

Example: Each data entry of users is processed individually by the CALL clause. If users has N entries, the CALL clause will execute N times; within each execution of the CALL clause, the path query clause and the SKIP clause execute once each.

UQL
find().nodes({@user}) as users
call {
  with users
  n(users).e()[:2].n() as paths
  skip 2
  return paths
}
return paths

BATCH Clause

The BATCH clause partitions data into smaller batches for sequential processing by the subsequent clause, thereby reducing memory usage.

Example: The (maximum) 5000 nodes in users are put into 50 batches, each containing 100 nodes. Nodes in each batch are automatically collected into an array and passed into the path template query, which is thus executed for 50 times.

UQL
find().nodes({@user.age_level == 4}) limit 5000 as users
BATCH 100
n(users).e().n({@ad} as ads)
GROUP BY ads.cate
RETURN table(ads.cate, count(ads.cate))

LIMIT and limit()

The LIMIT clause restricts the number of data entries contained in an alias. In chained clauses, the limit() method is employed to confine the number of data entries returned in each clause execution.

Example: In both statements, the find().nodes() clause executes twice, but the outcomes vary.

  • In part (a), the limit(2) method ensures that each query execution returns a maximum of two nodes.
  • In part (b), the LIMIT clause restricts the total number of nodes in result to a maximum of two.

OPTIONAL Prefix

The OPTIONAL prefix guarantees that each clause execution yields some result. If the query finds nothing, it returns null.

Example: Both statements involve two executions of the find().nodes() clause, with differing outcomes.

  • In part (a), the second query execution for the color black yields no return.
  • In part (b), the second query execution for color black returns null.