Pick of the Week at NebulaGraph - FETCH Syntax Goes Further with New Features
Normally the weekly issue covers Feature Explanation and Community Q&As. If something major happens, it will also be covered in the additional Events of the Week section.
This week, the
FETCH syntax has been armed with new features that let you retrieve the properties of multiple vertices for all their tags and facilitate your query for properties of multiple vertices further.
In NebulaGraph, the
FETCH syntax is used to query the properties of a vertex or an edge. Together with the variable and the pipe features, its new features make the
FETCH syntax more powerful in querying the properties of vertices.
Now, let's see what the
FETCH syntax is able to do.
Scenario #1: Retrieve all the properties from vertices for all their tags.
For example, we have two vertices and their IDs are 21 and 20 and we want to query all the properties of both vertices for all their tags and order the result by vertex ID. We cannot do that before, because the
FETCH syntax cannot be used to retrieve properties from multiple vertices for more than one tag. But now, we can use the
FETCH PROP ON * 21, 20; statement to get it done, as shown in the following figure.
Before this update, when you used the FETCH syntax to retrieve the properties from two vertices for two tags, such as
FETCH PROP ON t1, t2 20, 21; as shown in the following figure, an error was returned.
Scenarios #2: Use pipe to pass vertex IDs.
FETCH syntax supports querying properties based on vertex IDs that were passed by the PIPE (
| ) feature. For example, run the
YIELD 20 AS id | FETCH PROP ON t2 $-.id; statement to pass the id variable as the input of the FETCH statement, as shown in the following figure.
With this new feature, you can use the
GO syntax and the
FETCH syntax in one statement.
Scenarios #3: Use a variable to store vertex IDs.
This update enables you to store the queried vertex IDs as a variable and then retrieve the properties from the vertices for multiple tags by using the variable. For example, run the statements as follows and you will get the properties for the vertex (vid 20), as shown in the following figure.
$var = YIELD 20 AS id; FETCH PROP ON t2, t3 $var.id;
Q: My computer configurations are 32 GB memory and 16 cores. When I used importer to import data, the speed was about 10,000 rows per second. Is that reasonable? Is there anything I can do to speed up the data import?
A: If this is your first time to import data into NebulaGraph, we recommend that you delete the indexes from the data and then use the REBUILD INDEX statement to rebuild the indexes after the data is imported.
For the dataset to be imported, its indexes will reduce the import speed, because when a data record is imported, its index row will be the first one to be detected, and if most data in the dataset is unordered and the dataset size is large, more time will be consumed to detect such index rows. To avoid such problems, there are two options:
- ( Recommended ) Follow these steps: import data, create indexes, and then rebuild indexes.
- Import data in batch, a certain magnitude each time, and then perform compact after the import.
As per your case, it is unreasonable that the import speed is only tens of thousand of rows per second. The normal speed is:
- for import without indexes: 300 - 500 thousand rows per second
- for import with indexes: about 100 thousand rows per second.