@@ -246,6 +246,7 @@ def test_cached_execution(self):
246
246
247
247
def test_execution_plan (self ):
248
248
redis_graph = Graph ('execution_plan' , self .r )
249
+ # graph creation / population
249
250
create_query = """CREATE
250
251
(:Rider {name:'Valentino Rossi'})-[:rides]->(:Team {name:'Yamaha'}),
251
252
(:Rider {name:'Dani Pedrosa'})-[:rides]->(:Team {name:'Honda'}),
@@ -254,11 +255,11 @@ def test_execution_plan(self):
254
255
255
256
result = redis_graph .execution_plan ("""MATCH (r:Rider)-[:rides]->(t:Team)
256
257
WHERE t.name = $name
257
- RETURN r.name, t.name, $params
258
+ RETURN r.name, t.name
258
259
UNION
259
260
MATCH (r:Rider)-[:rides]->(t:Team)
260
261
WHERE t.name = $name
261
- RETURN r.name, t.name, $params """ , {'name' : 'Yehuda ' })
262
+ RETURN r.name, t.name""" , {'name' : 'Yamaha ' })
262
263
expected = '''\
263
264
Results
264
265
Distinct
@@ -290,6 +291,59 @@ def test_execution_plan(self):
290
291
291
292
redis_graph .delete ()
292
293
294
+ def test_profile (self ):
295
+ redis_graph = Graph ('profile' , self .r )
296
+ # graph creation / population
297
+ create_query = """UNWIND range(1, 30) as x CREATE (:Person {id: x})"""
298
+ redis_graph .query (create_query )
299
+
300
+ plan = redis_graph .profile ("""MATCH (p:Person)
301
+ WHERE p.id > 15
302
+ RETURN p""" )
303
+
304
+ results = plan .structured_plan
305
+ self .assertEqual (results .name , "Results" )
306
+ self .assertEqual (results .profile_stats .records_produced , 15 )
307
+ self .assertGreater (results .profile_stats .execution_time , 0 )
308
+
309
+ project = results .children [0 ]
310
+ self .assertEqual (project .name , "Project" )
311
+ self .assertEqual (project .profile_stats .records_produced , 15 )
312
+ self .assertGreater (project .profile_stats .execution_time , 0 )
313
+
314
+ filter = project .children [0 ]
315
+ self .assertEqual (filter .name , "Filter" )
316
+ self .assertEqual (filter .profile_stats .records_produced , 15 )
317
+ self .assertGreater (filter .profile_stats .execution_time , 0 )
318
+
319
+ node_by_label_scan = filter .children [0 ]
320
+ self .assertEqual (node_by_label_scan .name , "Node By Label Scan" )
321
+ self .assertEqual (node_by_label_scan .profile_stats .records_produced , 30 )
322
+ self .assertGreater (node_by_label_scan .profile_stats .execution_time , 0 )
323
+
324
+ redis_graph .query ("CREATE INDEX FOR (p:Person) ON (p.id)" )
325
+
326
+ plan = redis_graph .profile ("""MATCH (p:Person)
327
+ WHERE p.id > 15
328
+ RETURN p""" )
329
+
330
+ results = plan .structured_plan
331
+ self .assertEqual (results .name , "Results" )
332
+ self .assertEqual (results .profile_stats .records_produced , 15 )
333
+ self .assertGreater (results .profile_stats .execution_time , 0 )
334
+
335
+ project = results .children [0 ]
336
+ self .assertEqual (project .name , "Project" )
337
+ self .assertEqual (project .profile_stats .records_produced , 15 )
338
+ self .assertGreater (project .profile_stats .execution_time , 0 )
339
+
340
+ node_by_index_scan = project .children [0 ]
341
+ self .assertEqual (node_by_index_scan .name , "Node By Index Scan" )
342
+ self .assertEqual (node_by_index_scan .profile_stats .records_produced , 15 )
343
+ self .assertGreater (node_by_index_scan .profile_stats .execution_time , 0 )
344
+
345
+ redis_graph .delete ()
346
+
293
347
def test_query_timeout (self ):
294
348
redis_graph = Graph ('timeout' , self .r )
295
349
# Build a sample graph with 1000 nodes.
0 commit comments