How to speed up queries?

Hello.

I have a graph with about 20 millions of vertices with attributes:

vert1 (attr1, attr2, attr3, … attr20)

I need to implement queries like
select vert1 where attr1=‘x’ and attr2=‘y’ or ( attr3=‘z’ and attr4='x").

How can we speed up those queries? Probably add some indices or maybe change schema completely?

Hi Dmitry,

In 3.0, which will be released in the near future, we will support indexing on vertex attributes.

For now, you can consider creating vertex types for those attributes. Then connect the original vertexes to the attribute vertexes.

When you run a query, you can directly start from vertex attr1 attr2 attr3 and attr4 having x y z x as their ID and return vertexes that are connected to all of the input attribute vertexes.

Thanks.

I have the same requirement. Please can you provide a sample query for this. How exactly do you code for : return vertexes that are connected to all of the input attribute vertexes ?

1 Like

For this Query I’m taking the input ID of a person and grabbing all things connected to that person.

You will need to change “Person” for the “Vertex” that you designed.

CREATE QUERY edgeCrawl(VERTEX<Person> name)FOR GRAPH MyGraph {

 //Used to accumulate all connections
 ListAccum<EDGE> @@connectionList; 
	
     start = {name};  //pass name
	
    //From that person's name crawl all edges (notice I didn't specify an edge and left it blank with :e same with :t, by leaving the edge and target vertex blank it will traverse everything)
	S1 = SELECT s
	       FROM start:s -(:e)-> :t
	       ACCUM @@connectionList += e;
	
  PRINT  @@connectionList; 
}