Pipe operators¶
Multiple queries can be combined using pipe operators in nGQL.
OpenCypher compatibility¶
Pipe operators apply to native nGQL only.
Syntax¶
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.
Examples¶
nebula> GO FROM "player100" OVER follow \
YIELD dst(edge) AS dstid, properties($$).name AS Name | \
GO FROM $-.dstid OVER follow YIELD dst(edge);
+-------------+
| dst(EDGE) |
+-------------+
| "player100" |
| "player102" |
| "player125" |
| "player100" |
+-------------+
Users must define aliases in the YIELD
clause for the reference operator $-
to use, just like $-.dstid
in the preceding example.
Performance tips¶
In NebulaGraph, 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
A
before the pipe operator is completed. -
If
A
sends a large amount of data to|
, the entire query request may be very slow. You can try to split this statement.-
Send
A
from 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 | B
with a single graphd process. -