diff --git a/src/service/clmcservice/graphapi/utilities.py b/src/service/clmcservice/graphapi/utilities.py
index 05082e99e49e80914c6597595e68f0a47e14d817..9d8dd6808a5fc16440d65bb128fa6da17fe39f51 100644
--- a/src/service/clmcservice/graphapi/utilities.py
+++ b/src/service/clmcservice/graphapi/utilities.py
@@ -223,14 +223,15 @@ def delete_nodes_with_type(graph, node_type):
 
     log.info("Deleting {0} nodes.".format(node_type))
 
-    subgraph = graph.nodes.match(node_type)
-    deleted_nodes = len(subgraph)
-    for node in subgraph:
-        graph.delete(node)
+    # this is the recommended way to delete a number of nodes, rather than deleting them one by one
+    query = "MATCH (node:{0}) DETACH DELETE node RETURN count(node) as count;".format(node_type)
+    log.info("Executing query {0}".format(query))
+    result = graph.run(query)
+    nodes_matched = result.data()[0]["count"]  # we expect exactly one result, which is a dictionary with key 'count'
 
-    log.info("Deleted {0} {1} nodes.".format(deleted_nodes, node_type))
+    log.info("Deleted {0} {1} nodes.".format(nodes_matched, node_type))
 
-    return deleted_nodes
+    return nodes_matched
 
 
 def build_temporal_subgraph(request_id, from_timestamp, to_timestamp, json_queries, graph, influx_client):
@@ -338,11 +339,11 @@ def delete_temporal_subgraph(graph, subgraph_id):
 
     log.info("Deleting subgraph associated with ID {0}".format(subgraph_id))
 
-    subgraph = graph.nodes.match(uuid=subgraph_id)
-    nodes_matched = 0
-    for node in subgraph:
-        graph.delete(node)
-        nodes_matched += 1
+    # this is the recommended way to delete a number of nodes, rather than deleting them one by one
+    query = "MATCH (node {{uuid: '{0}'}}) DETACH DELETE node RETURN count(node) as count;".format(subgraph_id)
+    log.info("Executing query {0}".format(query))
+    result = graph.run(query)
+    nodes_matched = result.data()[0]["count"]  # we expect exactly one result, which is a dictionary with key 'count'
 
     log.info("Deleted {0} nodes associated with ID {1}".format(nodes_matched, subgraph_id))