Skip to content

Commit ace7caa

Browse files
updated query to massively improve the speed of fetching metadata by not needing to page through the result set
1 parent 593f6aa commit ace7caa

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

src/app_neo4j_queries.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,15 +1198,12 @@ def get_entities_by_uuid(neo4j_driver,
11981198
"""
11991199
def get_batch_ids(neo4j_driver, id_list):
12001200
query = """
1201-
UNWIND $id_list AS uid
1202-
MATCH (e:Entity {uuid: uid})
1203-
RETURN uid AS uuid, e.hubmap_id AS hubmap_id
1201+
MATCH (e:Entity)
1202+
WHERE e.uuid IN $id_list
1203+
RETURN apoc.map.fromPairs(COLLECT([e.uuid, e.hubmap_id])) AS result
12041204
"""
12051205

1206-
result_dict = {}
1207-
12081206
with neo4j_driver.session() as session:
1209-
result = session.run(query, id_list=id_list)
1210-
for record in result:
1211-
result_dict[record["uuid"]] = record["hubmap_id"]
1212-
return result_dict
1207+
record = session.run(query, id_list=id_list)
1208+
raw = record.single()["result"]
1209+
return {uuid: {"uuid": uuid, "hubmap_id": hubmap_id} for uuid, hubmap_id in raw.items()}

0 commit comments

Comments
 (0)