0

I am working on a route suggestion system between 2 locations. I have a "Locations" document collection(1K docs) and "Service" edge collection(10 lack docs). When I am trying to print all possible routes between 2 random locations, the query is taking forever to run. I have attached the query below. My question here is : Is there any other way of traversing the graph? Is this a common issue or the query is not efficient? Can anyone suggest me some good read on this? QUERY:

let fromDoc= (for loc in Location
sort rand()
limit 1
return loc._id)
let toDoc= (for loc in Location
sort rand()
limit 1
return loc._id)
let pathList = (FOR v, e, p IN 1..3 OUTBOUND fromDoc[0] Service
     filter v._id == toDoc[0]
     RETURN p)
return pathList

Thanks in advance Archana

  • Based on those numbers, every document has a connection to every other document? It's a 'highly' interconnected graph, so yes, there will be a lot of work for the database to deal with, I'm not sure of the real world use case this aligns with. One thing to do is return RETURN DISTINCT p in your query, to reduce the amount of data returned, but also to think about how much RAM and CPU the machine has. Do you have an example use case that this level of connectedness is appropriate for? – David Thomas Apr 02 '20 at 09:07
  • Hi David, The use case here is public transport system of a city (Bangalore for example). This is a highly interconnected graph. The system configuration is Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 And in my view returning distinct p will not reduce any burden on the DB. What other options you suggest? – Archana S Apr 03 '20 at 10:08
  • So, in the example of a bus network, your vertexes are 'stops' and your edges have a key that stores what bus number is taken? or are the edges just all the possible connections, where the bus could be changing a lot? If you wanted to see how someone could travel without leaving a bus, then ensuring all edges between nodes has the same bus number will greatly reduce the processing (i think). – David Thomas Apr 06 '20 at 00:22

0 Answers0