hubmapconsortium / entity-api

A set of web service calls to return information about HuBMAP entities
https://entity.api.hubmapconsortium.org
MIT License
3 stars 1 forks source link

Simple Neo4j query tuning for read triggers #645

Closed yuanzhou closed 2 months ago

yuanzhou commented 3 months ago

After analyzing the two profiling results from https://github.com/hubmapconsortium/entity-api/issues/641, I identified two read triggers that can benefit from some very simple neo4j query tuning.

Read trigger get_sample_direct_ancestor() issues the neo4j query defined in get_sample_direct_ancestor()

This trigger only applies to Sample. In the MATCH clause, change (e:Entity) to (e:Sample) will reduce the total number of db hits and unnecessary filtering.

Screenshot 2024-03-20 at 2 09 35 PM

Read trigger get_creation_action_activity() issues the neo4j query defined in get_entity_creation_action_activity()

This trigger only applies to Dataset. In the MATCH clause, by specifying ds:Dataset label we'll reduce the total number of db hits and unnecessary filtering.

Screenshot 2024-03-20 at 2 00 19 PM