Multiple queries can be combined using pipe operators in nGQL.
Pipe operators apply to native nGQL only.
One major difference between nGQL and SQL is how sub-queries are composed.
- In SQL, sub-queries are nested in the query statements.
- In nGQL, the shell style
PIPE (|)is introduced into the sub-queries.
nebula> GO FROM "player100" OVER follow \ YIELD dst(edge) AS dstid, properties($$).name AS Name | \ GO FROM $-.dstid OVER follow; +-------------+ | follow._dst | +-------------+ | "player100" | | "player102" | | "player125" | | "player100" | +-------------+
If there is no
YIELD clause to define the output, the destination vertex ID is returned by default. If a YIELD clause is applied, the output is defined by the YIELD clause.
Users must define aliases in the
YIELD clause for the reference operator
$- to use, just like
$-.dstid in the preceding example.
In Nebula Graph, pipes will affect the performance. Take
A | B as an example, the effects are as follows:
Pipe operators operate synchronously. That is, the data can enter the pipe clause as a whole after the execution of clause
Abefore the pipe operator is completed.
Pipe operators need to be serialized and deserialized, which is executed in a single thread.
Asends a large amount of data to
|, the entire query request may be very slow. You can try to split this statement.
Afrom the application,
Split the return results on the application,
Send to multiple graphd processes concurrently,
Every graphd process executes part of B.
This is usually much faster than executing a complete
A | Bwith a single graphd process.