I am new to TigerGraph and GSQL. The database is running on an Azure VM with 8 vCPUs and 32GB memory. I have a dataset of about 250,000 edges and 300,000 nodes. All vertex attributes are indexed. I have several problems/questions, but first let me show the query and example response.
Here’s the query:
CREATE QUERY downstream(VERTEX<MaterialPlantVertex> starting_vertex) FOR GRAPH SimpleMassBalance {
vertices = {starting_vertex};
SetAccum<EDGE> @@edges;
WHILE vertices.size() > 0 DO
vertices = SELECT t FROM vertices:s -( MaterialPlantEdge >:e)- :t
ACCUM @@edges += e;
PRINT @@edges;
PRINT vertices;
END;
}
Here’s an example response:
[
{
"@@edges": [
{
"attributes": {
"Quantity": -335.29599,
"Type": "Production",
"UomCode": "kg",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A001 | 10001056",
"from_type": "MaterialPlantVertex",
"to_id": "A010 | 10096038",
"to_type": "MaterialPlantVertex"
}
]
},
{
"vertices": [
{
"attributes": {
"BusinessCode": "27304",
"BusinessDescription": "27304_ADHESIVES",
"MaterialCode": "10096038",
"MaterialDescription": "10096038_ADCOTE 812/BASE BULK",
"OffsetQuantity": 7220,
"PerformanceCenterCode": "25718",
"PerformanceCenterDescription": "25718_LAM POLYURETHANE",
"PlantCode": "A010",
"PlantDescription": "A010_West Alexandria AFP",
"ValueCenterCode": "16762",
"ValueCenterDescription": "16762_LAMINATING ADHESIVES"
},
"v_id": "A010 | 10096038",
"v_type": "MaterialPlantVertex"
}
]
},
{
"@@edges": [
{
"attributes": {
"Quantity": 1850,
"Type": "STO",
"UomCode": "KG",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A010 | 10096038",
"from_type": "MaterialPlantVertex",
"to_id": "A051 | 11135745",
"to_type": "MaterialPlantVertex"
},
{
"attributes": {
"Quantity": 10034,
"Type": "309_TF tfr ps.mat.to mat",
"UomCode": "kg",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A010 | 10096038",
"from_type": "MaterialPlantVertex",
"to_id": "C466 | 99048702",
"to_type": "MaterialPlantVertex"
},
{
"attributes": {
"Quantity": -335.29599,
"Type": "Production",
"UomCode": "kg",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A001 | 10001056",
"from_type": "MaterialPlantVertex",
"to_id": "A010 | 10096038",
"to_type": "MaterialPlantVertex"
}
]
},
{
"vertices": [
{
"attributes": {
"BusinessCode": "16979",
"BusinessDescription": "16979_CONSTRUCTION CHEMICALS",
"MaterialCode": "11135745",
"MaterialDescription": "11135745_PRIMAL EC-2019R AF/BULK",
"OffsetQuantity": 62648,
"PerformanceCenterCode": "17014",
"PerformanceCenterDescription": "17014_CONSTRUCTION",
"PlantCode": "A051",
"PlantDescription": "A051_Queretaro Coatings",
"ValueCenterCode": "17009",
"ValueCenterDescription": "17009_CONSTRUCTION"
},
"v_id": "A051 | 11135745",
"v_type": "MaterialPlantVertex"
},
{
"attributes": {
"BusinessCode": "NA",
"BusinessDescription": "NA",
"MaterialCode": "99048702",
"MaterialDescription": "99048702_SHPOL NF-1159M2 THDR 210KG",
"OffsetQuantity": 8111,
"PerformanceCenterCode": "NA",
"PerformanceCenterDescription": "NA",
"PlantCode": "C466",
"PlantDescription": "C466_Guangzhou Systems House",
"ValueCenterCode": "NA",
"ValueCenterDescription": "NA"
},
"v_id": "C466 | 99048702",
"v_type": "MaterialPlantVertex"
}
]
},
{
"@@edges": [
{
"attributes": {
"Quantity": 1850,
"Type": "STO",
"UomCode": "KG",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A010 | 10096038",
"from_type": "MaterialPlantVertex",
"to_id": "A051 | 11135745",
"to_type": "MaterialPlantVertex"
},
{
"attributes": {
"Quantity": 10034,
"Type": "309_TF tfr ps.mat.to mat",
"UomCode": "kg",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A010 | 10096038",
"from_type": "MaterialPlantVertex",
"to_id": "C466 | 99048702",
"to_type": "MaterialPlantVertex"
},
{
"attributes": {
"Quantity": -335.29599,
"Type": "Production",
"UomCode": "kg",
"UomDescription": "KG"
},
"directed": true,
"e_type": "MaterialPlantEdge",
"from_id": "A001 | 10001056",
"from_type": "MaterialPlantVertex",
"to_id": "A010 | 10096038",
"to_type": "MaterialPlantVertex"
}
]
},
{
"vertices": []
}
]
Problems:
- The query is timing out (16+ seconds) when result set is greater than ~10 nodes/edges. Is there something wrong with my query?
- The same edges are listed more than once. Search for
A001 | 10001056
in the output - The resultant JSON is in a very strange (to me) format. Is it possible to just have an array of vertices and an array of edges?
- Having the @ character in property names of JSON is not a good practice. Is it possible to remove them in the JSON?